Please sign in to comment.
MDL-30168 formslib: untangle automatic id generation.
Previously, we had overridden the _generateId method in almost all subclasses; and then we mostly, but not always; ignored the value that was generated there, and instead generated new (nicer) values in MoodleQuickForm_Renderer::renderElement. Of course, that is not really a logical place to (re)generate ids. I have fixed the code so that the _generateId method now uses the 'nice id' algorithm from renderElement. This should make the whole code flow more logical. This make all our overriding of _generateId unnecessary. We do need a special _generateId for radio buttons, because you often have different radio buttons with the same name but different values. This change should only change the ids on radio, checkbox and advcheckbox elements. Previously, those were essentially random, so I don't think anyone could have been relying on the particular values. This commit also has new unit tests, first to test the basic _generateId algorithm, and then to create and render an example form (including some tricky things like repeat_elements) and chech the acutal ids in the generated HTML.
- Loading branch information...
Showing with 130 additions and 159 deletions.
- +0 −18 lib/form/advcheckbox.php
- +0 −17 lib/form/checkbox.php
- +0 −17 lib/form/radio.php
- +0 −17 lib/form/select.php
- +0 −18 lib/form/selectgroups.php
- +0 −17 lib/form/selectwithlink.php
- +0 −17 lib/form/text.php
- +0 −17 lib/form/url.php
- +2 −11 lib/formslib.php
- +0 −1 lib/pear/HTML/QuickForm/checkbox.php
- +9 −7 lib/pear/HTML/QuickForm/element.php
- +16 −2 lib/pear/HTML/QuickForm/radio.php
- +103 −0 lib/simpletest/testformslib.php