It seems inconsistent to me that submit buttons are not wrapped in a div.form-item
like everything else in a form. I would like them to be wrapped as such for theming reasons (perhaps wrapped in something like div.form-item.form-button
), although I recognize that would change the appearance of a lot of existing themes so it can't go into Drupal 7.
As another related request, I'd like to see all Drupal core forms wrap the submit buttons in a single div with a consistent class so that, as a common use case example, the buttons can all be centered together. Ideally this would be done with a '#type' => 'buttons'
that uses the #options directive or something similar that would allow for different #button_type values (if #button_type were extended to affect the type of the button; otherwise, we would need to create a separate '#type' => 'submit_buttons'
). As I recall, however, even when using the following:
<button type="submit" name="submit_action" value="save">Save this post</button>
$form_state['values']['submit_action']
might end up being "save" or "Save this post" depending on the browser (stupid old internet explorer). So instead, the submit buttons for every Drupal form might need to be wrapped like so:
$form['buttons'] = array(
'#prefix' => '<div class="form-item form-buttons" id="submit_action">',
'#suffix' => '</div>',
);
$form['buttons']['save'] = array(
'#type' => 'submit',
'#title' => t('Save'),
'#submit' => array('mymodule_save_content'),
);
$form['buttons']['preview'] = array(
'#type' => 'submit',
'#title' => t('Preview'),
'#submit' => array('mymodule_preview_content'),
);