Fieldset is under Save-Button if another module changes '#weight' of a fieldset

marenz - May 17, 2008 - 09:15
Project:Drupal
Version:6.2
Component:forms system
Category:bug report
Priority:normal
Assigned:marenz
Status:by design
Description

In a hook_user of my module I wrote
$form['picture'] = array('#weight' => 10);
to bring the picture fieldset to the bottom of the form. But it's to much to the bottom, it is UNDER the Save button. This also happens to other fieldsets if I try to overwrite their weight.

Already tried out to find the reason, but only could find the function weight_value() in form.inc, which isn't called from anywhere.

#1

blakehall - October 30, 2008 - 03:19
Status:active» by design

The 'form' op of hook_user is for _injecting_ form elements into the form rather than modifying them. Trying to use hook_user to do this, alters the form array to look like:

<?php
$form
['picture']['#weight'] = array( 0 => 10, 1 => 1);
?>

Your module could use hook_form_alter to reset the weight of the picture element like:

<?php
 
 
function userfix_form_alter(&$form, $form_state, $form_id) {
   
$form['picture']['#weight'] = 11;
  }
?>

(The weight on the submit button is 30, by default).

Hope this helps.

 
 

Drupal is a registered trademark of Dries Buytaert.