- From: <jeffrey@janoah.com>
- Date: Sat, 15 Feb 2025 01:14:16 +0000
- To: www-forms@w3.org
- Message-ID: <560ad854374e94a0adbb3a7347c358cd@webmail.tigertech.net>
I am actively developing a Laravel PHP application that heavily uses HTML Forms. I recently ran into a problem where I'm posting form data to a route that spans across multiple <div> and it includes additional forms inside modal windows (which I really like). The problem is I want all of the form buttons to be on a single row and they submit to different routes and different types (POST, DELETE) for example. And we know we can't have embedded forms (which I agree with). So I propose: An Enhanced Form Segmentation in HTML where a single form can be spread across multiple <form> tags maintaining the ability to submit all parts as one cohesive unit. This enables complex form layouts especially when different parts of the form need to be interspersed with other interactive elements like my favorite modals. Proposed Solution: * Form Segment Attribute: Introduce a new attribute, e.g., data-form-segment, which can be used on <form> elements to indicate they are segments of a larger, logical form. * Example: <form id="formPart1" method="POST" action="/submit-all" data-form-segment="mainForm"> <!-- First segment of the form --> </form> <!-- Other content or forms here --> <form id="formPart2" method="POST" action="/submit-all" data-form-segment="mainForm"> <!-- Second segment of the form --> </form> * Submission Mechanism: Define how these segments work together: * If one segment is submitted, all segments with the same data-form-segment value should ideally be considered for submission. * A new form attribute, e.g., form-submit-all, could be used on submit buttons within these segments to indicate that it should submit data from all segments with the matching data-form-segment value: <button type="submit" form-submit-all="mainForm">Submit All Segments</button> * Browser Behavior: * Browsers would need to implement logic to collect data from all matching segments when a form-submit-all button is pressed. * For security, ensure that all form segments are within the same document and context to prevent unauthorized data aggregation. Use Cases: * Complex Layouts: Allows developers to create forms that span across different UI sections or modals without having to manage data collection manually. * User Experience: Enhances UX by allowing forms to be visually and functionally segmented while still acting as one when submitted. Potential Challenges: * Security: Ensuring that data from different segments can't be tampered with or submitted unintentionally. * Backward Compatibility: New attributes and behaviors need to be introduced without breaking existing implementations. * Accessibility: Ensuring that this doesn't complicate form accessibility for users with disabilities. * Browser Implementation: Uniform implementation across different browsers to maintain a consistent web experience. Implementation Considerations: * JavaScript Fallback: For browsers without native support, a JavaScript polyfill could manage the collection of form data from segments. * Server-Side Handling: Servers would need to be prepared to handle data from segmented forms as one submission. Conclusion: This proposal aims to extend HTML's form capabilities to better match modern web design needs, providing developers with more flexibility in layout and interaction without compromising functionality. This proposal would need to be refined further, possibly with more detailed examples, browser compatibility considerations, and perhaps even a polyfill or prototype to show how this could work in practice. I welcome your feedback. Jeffrey Thompson IT Consultant JANOAH INC Sarasota, FL 941-233-2925 jeffrey@janoah.com (mailto:jeffrey@janoah.com) website: janoah.com (http://janoah.com)
Received on Thursday, 24 April 2025 20:47:55 UTC