I am writing a module in which a fieldset containing a bunch of buttons gets added to the edit/add node form using hook_form_alter.
The fieldset(the buttons) are supposed to be connected to a certain widget for a field. For example maybe the body field widget of content type 'myContentType'. I always want the fieldset and the widget of the field to be placed together in the form, preferably with the fieldset above the widget. So to achieve this I thought I would use the #weight property of the form elements.
So in hook_form_alter I set:
$form['buttonFieldset'][#weight] = $form['body']['#weight'] - 1;
Afterwards I check in the $form array and the weight of the button field did get set to a weight one smaller than the associated widget. I thought this would place it right above the textarea of the body, but this did not happen. Does anyone know why not? Or some other way to achieve what I want?