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.
On 10/11/2011 1:34 AM, sebastian wrote:
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.
Try the devel_themer module. When it is enabled, users with the proper permissions can click on any element and get information on all the theme functions used to generate that content, starting at the lowest nested level.
Ted
Thanks Ted,
I've tried that and I get the following:
form < page < overlay < html
Form is what I want, as after that it is field-level.
It lists function:
theme_form()
http://api.drupal.org/api/drupal/includes--form.inc/function/theme_form/7
and candidate:
form() [no other candidates listed]
with an array containing the $form and another that says:
'them_hook_suggestions' that is a null-array [no suggestions] ['them_hook_suggestions'] = null
Presumably I can't put theme_form() in my theme, I need to add a theme_hook_suggestion...?
If so, I guess my questions are:
1.) How can I add a suggestion to "look" at my theme?
and
2.) How to then access this function?
Presumably if 1.) is logical 2) will be answered at the same time.
Like if I could add the suggestion:
THEME_page_form_edit(&$form) {}
In case I am not clear, this is to edit the forms' theme for pages like:
node/edit block/edit
in Drupal 7.
I hope I am still making sense.
Thanks for your help!
Best,
Sebastian.
On 2011-10-11 8:15 PM, Ted wrote:
On 10/11/2011 1:34 AM, sebastian wrote:
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.
Try the devel_themer module. When it is enabled, users with the proper permissions can click on any element and get information on all the theme functions used to generate that content, starting at the lowest nested level.
Ted
I've never heard of THEME_form_hook_alter().
template.php is generally for theme override functions. That is, the functions in this file will be overriding the output of existing theme functions which are defined by hook_theme.
Drupal themes only serve to rewrite existing output. All original output in Drupal is defined by theme functions, which appear modules. The stark theme is a nice working example of this -- notice that there are no included templates. Markup starts with modules.
In your case, you have only defined the override, not the originating theme function. So, in your module, you need to so something like the following: http://pastebin.com/vkXbxeX7
This will require a cache clear such that the theme registry will now know about hook_theme().
Carl Wiedemann Website design and development consulting carl.wiedemann@gmail.com | skype: c4rlww
On Mon, Oct 10, 2011 at 11:34 PM, sebastian inforazor@gmail.com wrote:
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.
[ Drupal support list | http://lists.drupal.org/ ]
Hello Carl and Others,
Thanks for your code sample. I must say however I couldn't get it to work as the theme function: node_page_edit is never called...? And I'm at a loss how this is supposed to work? Maybe it's just me...
Instead I got Eclipse+XDebug installed, something I've been wanting to do for a while and watched some more videos on Drupal 7's changes on Form/Array rendering API.
My approach was to go back to the array variable itself, with HOOK_form_FORM_ID_alter() and to add, move and change the values there, combined with HOOK_page_alter() and I've gotten it all working correctly now.
Thank you all for your time and assistance!
Sincerely,
Sebastian.
On 2011-10-11 9:18 PM, Carl Wiedemann wrote:
I've never heard of THEME_form_hook_alter().
template.php is generally for theme override functions. That is, the functions in this file will be overriding the output of existing theme functions which are defined by hook_theme.
Drupal themes only serve to rewrite existing output. All original output in Drupal is defined by theme functions, which appear modules. The stark theme is a nice working example of this -- notice that there are no included templates. Markup starts with modules.
In your case, you have only defined the override, not the originating theme function. So, in your module, you need to so something like the following: http://pastebin.com/vkXbxeX7
This will require a cache clear such that the theme registry will now know about hook_theme().
Carl Wiedemann Website design and development consulting carl.wiedemann@gmail.com mailto:carl.wiedemann@gmail.com | skype: c4rlww
On Mon, Oct 10, 2011 at 11:34 PM, sebastian <inforazor@gmail.com mailto:inforazor@gmail.com> wrote:
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. -- [ Drupal support list | http://lists.drupal.org/ ]