Forms API #id questions
I'm in the habit of giving nearly every form element an #id because I've been doing lots of AJAX stuff and always have the need to grab things in the DOM. Can someone comment on this bit of instruction: http://drupaldocs.org/api/head/file/contributions/docs/developer/topics/form... Is the use of #id discouraged? Why is there no #id property allowed on hidden form elements? Thanks Robert
On Sun, 15 Jan 2006 11:04:45 +0100, Robert Douglass <rob@robshouse.net> wrote:
I'm in the habit of giving nearly every form element an #id because I've been doing lots of AJAX stuff and always have the need to grab things in the DOM. Can someone comment on this bit of instruction: http://drupaldocs.org/api/head/file/contributions/docs/developer/topics/form...
Is the use of #id discouraged?
For your convinience, it's automatically created from #parents which again autocreated from #tree. But if you do not like this autocreated #id , feel free to provide your own, form API will honor it.
Why is there no #id property allowed on hidden form elements?
Feel free to roll a patch against theme_hidden.
Why is there no #id property allowed on hidden form elements?
Feel free to roll a patch against theme_hidden.
Automatic id's were removed for hidden elements, because having the same form twice on a page would cause <input type="hidden" name="form_id" id="form_id" /> to appear twice, breaking XHTML validation. But you can add an id manually with '#attributes' => array('#id' => 'foo'), there is nothing that disallows it. Steven
participants (3)
-
Karoly Negyesi -
Robert Douglass -
Steven Wittens