Hi,
I've been testing the cvs HEAD version and I'm completley unclear on the new forms API. I've read the documentation, but it is certainly lacking (or I am missing something or perhaps just misunderstanding something).
How does one override the forms output via themes?
The API makes custom theming of all forms (including those found in core) possible.
The above line is under "Theming Forms" in the documentation, but what it describes seems to be at the module/code level. If I am using phpTemplate for the template engine, how do I override the forms?
I ask because I would LOVE if I could get rid of all the divs on the forms created by core modules (the contact form, for example) where each label/input pair is in its own div. I'd also prefer to wrap sets of form inputs in fieldsets and do some other stuff. Is this possible with this new forms API or am I only dreaming?
Comments
It is, in fact, possible.
..But it takes a good deal of work. ;-)
I believe that there's some good documentation on it being put together, but in a nutshell the answer is 'yes.' You can override how various types of form elements are 'rendered' into HTML, override the layouts of specific forms, and so on.
I'd recomment NOT tackling it until 4.7 hits release candidate, to be honest. This area in particular is still in the process of being tweaked and debugged.
--
Jeff Eaton | Click Here To Find Out Why Drupal "Sucks"
--
Eaton — Partner at Autogram
Lots of new theme hooks
There are at least three levels of things where you can do something. One, form elements are now theme_something, like theme_select. Two, when you declare your form you may use #theme attribute for any part of the form (be it just one field or a bigger part). Three, you may have theme($form_id,...) for every $form_id and if drupal_get_form is called by three parameters then theme($callback... too.
--
Read my developer blog on Drupal4hu.
--
Drupal development: making the world better, one patch at a time. | A bedroom without a teddy is like a face without a smile.