By khanz on
I have a node type 'review' which is attached to two vocabularies and are appearing in a fieldset named VOCABULARIES in the node form.
But what i don't want them to be in a fieldset, so i created this module. But am not having any success with it. I increased the module weight after reading the forums but still nothing. Can any one tell me what i am doing wrong here..?
function mymodule_form_alter(&$form, $form_state, $form_id) {
if ($form_id == 'review_node_form') {
$form['taxonomy'][2]['#collapsible'] = FALSE;
$form['taxonomy'][3]['#collapsible'] = FALSE;
}
}
Comments
I haven't looked at the
I haven't looked at the specifics of the taxonomy fieldset, but in the past when wanting to remove fieldsets, I've done this.
First, lets assume that the original form definition looks like this:
Then in hook_form_alter, I would do this:
This assigns the part you want to keep to a new form element, then clears out the entire last element. The important part is that you keep the name of the element exactly the same, as submit functions will be looking for that specific name. You can see that I named the new element $form['item'], as the old element was $form['fieldset']['item'].
Note: There are a few circumstances where this won't work because the original form submission function is set to work with the tree, so taking out one element screws things up. This is quite a rare case though.
Contact me to contract me for D7 -> D10/11 migrations.
.:
thanks for the detailed reply.. i used above solution somewhat like this...
but it removes the taxonomy field completely. i guess am not able to find correct element name, so how can i find the exact name??
------------
Volvo, Video, Velcro. (I came, I saw, I stuck around.)
Ya, mine was just an
Ya, mine was just an example.
To find the element, do this:
Contact me to contract me for D7 -> D10/11 migrations.
My version: function
My version:
MfG
CKIDOW
This one works
If anyone is looking for a solution to this, I haven't tried the ones above, but here is a simple one that I found which works. Implement a hook_form_alter function as below.
Note that the important line is the one inside the if statement. The rest is implementation-specific.
source: http://drupalbin.com/13098
This is fantastic. Thanks.
This is terrific. Thanks.
Luis
Thanks
Dude,
Its great and thanks for the same...
This has been integrated into
This has been integrated into Node Form Settings 6.x-2.x
Luis
Using dsm() function created
Using the dsm() function provide by the Development (devel) module (http://drupal.org/project/devel) is something I would recommend to anybody looking to analyze and make changes like this one to a form. It could save you hours of trying to understand the complex nested array. It creates a collapsible readout that makes it easy to identify and drill down to nested array elements:
Thanks for the tip. It
Thanks for the tip. It definitely is tedious trying to understand those arrays. One question: Where would you place this code in a situation like this? Just in page.tpl.php?
Thanks
Usually this would be inside
Usually this would be inside a call to hook_form_alter (http://api.drupal.org/api/function/hook_form_alter) which is in a custom module. However it is possible to get control of a form through the theme layer in template.php but it requires a couple of extra steps - see http://www.lullabot.com/articles/modifying-forms-drupal-5-and-6 for an example.