[support] how to Form Render-Alter in D7?

sebastian inforazor at gmail.com
Tue Oct 11 05:34:18 UTC 2011


Hello,

Very sorry to ask this, but I am going in a loop with the documentation, 
and the IRC chat isn't helping much either... so I hope this won't take 
much of your time.

I understand in D7 that we can write in a custom module for form 
alterations such as:

file: webadmin_ui.module
//this is a custom module I made

function webadmin_ui_form_page_node_form_alter(&$form, &$form_state, 
$form_id) {
	dpm ($form);//see values
	//change values as you please here...
}

And I also understand that in D7 we REMOVED the feature/function to 
alter the form values in the THEME layer, so this function was killed:

THEME_form_hook_alter($form) {}

Because supposedly I can theme it via different methods.

In the $form variable, when I DPM it [see above] I note the theme-chain:

dpm($form) outputs: [among other things]

$form['#theme']['page_node_form']
$form['#theme']['node_form']

If I try and be "smart" and write in my template.php:

mytheme_page_node_form($form) {
  dpm("it works!");
}

I clearly get nothing as this function is never called.

Can I add my own function call to this list? If so, how?

Is there documentation on this anywhere?

The documentation in D6 was a mess, and for this in D7 its really no 
better [maybe even worse cause I keep hitting D6 pages mixed into D7 
ones with no warning].

The whole point of all this is I want to understand how I can not only 
modify the form BEFORE it gets rendered, but also alter HOW the form is 
rendered... wrap some parts in a DIV, maybe add a missing CLASS or ID etc.

Ideas?

Thank you kindly,

Sebastian.


More information about the support mailing list