Wrap input[type="submit"] in a div.form-item

Created on 3 July 2012, about 12 years ago
Updated 27 June 2023, about 1 year ago

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'),
);
✨ Feature request
Status

Postponed: needs info

Version

9.5

Component
FormΒ  β†’

Last updated 1 minute ago

Created by

πŸ‡ΊπŸ‡ΈUnited States meustrus

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024