Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 3.2.16

Bug #925 form name attribute does not exist in xhtml1.1
Submitted: 2004-02-28 20:44 UTC
From: inside at parasiterecords dot com Assigned: avb
Status: Closed Package: HTML_QuickForm
PHP Version: Irrelevant OS: Irrelevant
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 15 + 20 = ?

 
 [2004-02-28 20:44 UTC] inside at parasiterecords dot com
Description: ------------ This is what I get when validating my xhtml1.1 document : <form action="/test2.php" method="post" name="myForm" id="myForm"> Error: there is no attribute name for this element (in this HTML version) The form attributes are generated in the HTML/QuickForm.php file like this : $attributes = array('action'=>$action, 'method'=>$method, 'name'=>$formName, 'id'=>$formName) + $target; Reproduce code: --------------- require_once "HTML/QuickForm.php"; $form = new HTML_QuickForm('myForm'); $form->addElement('text', 'name', 'Nom : '); $form->addElement('submit', 'btnSubmit', 'Submit'); if ($form->validate()) { $form->freeze(); } $form->display(); Expected result: ---------------- <form action="/test2.php" method="post" id="myForm"> Actual result: -------------- <form action="/test2.php" method="post" name="myForm" id="myForm">

Comments

 [2004-02-29 08:45 UTC] avb
The form's "name" attribute is currently used in JavaScript for form validation. It is also used in QuickForm_Controller package, so just removing the attribute will lead to some unfortunate BC issues. As for the JavaScript, this is an easy fix: we just have to pass a form object to the validation function. To prevent "name" attribute from appearing in the output, I suggest patching accept() method so that it removes "name" attribute before calling the renderer's methods and puts it back after this. Bertrand, what do you think?
 [2004-02-29 10:18 UTC] mansion at php dot net
We could also add a name property to the form object, instead of the attribute and use getName() instead of getAttribute('name'). If the developer wants a name attribute in his <form> tag, he should be free to do so using updateAttributes(), as he might be using some old javascript code relying on this. I think this way we don't need to change accept(). But we will have to find every places where getAttribute('name') is called.
 [2004-02-29 12:11 UTC] avb
I don't like the idea of adding Yet Another property and method. But you are right, if a person wants a 'name' attribute, he should be able to add it himself. I'll need to fix getAttribute('name') in QFC so that it will use 'id' instead and roll out a new release. Then I suggest the following: we should introduce a constant, say 'QUICKFORM_XHTML_COMPLIANCE'. If that is defined, don't set form's name attribute in constructor. By default it will be disabled, those wishing XHTML compliance should enable it. Also we'll add a note that it will be the default behaviour in next major release. Comments?
 [2004-02-29 12:13 UTC] avb
Sorry, it was unclear, I really meant "By default it will not be defined, those wishing XHTML compliance here and now should define it."
 [2004-03-01 20:38 UTC] avb
OK, at last: the constant is not really needed, as everyone needing XHTML compliance is able to use $form->removeAttribute('name'); even now. QF and QFC will be fixed to remove all internal dependencies on form's name attribute.
 [2004-03-02 21:10 UTC] avb
Fixed in CVS. QF does not use "name" attribute of form internally anymore, it is still set by the constructor though (BC issues). If you don't want the attribute to appear in output, use $form->removeAttribute('name');