Drupal 7 button creation instead of input='submit'

Drupal 7 doesn't allow us to override the theme_button(&$variables) function even if you use hook_theme_registry_alter(). A kinda ugly method was found but doesn't fall to far from standards.

$form['buttons']['continue'] = array(
  '#type' => 'submit',
  '#value' => '',
  '#attributes' => array('style' => array('display: none')),
  '#validate' => array('commerce_checkout_form_validate'),
  '#submit' => array('commerce_checkout_form_submit'),
  '#prefix' => '<button type="submit" class="btn btn-primary">Next',
  '#suffix' => '</button>',
);

 

Source: https://drupal.stackexchange.com/questions/13796/generating-button-type-submit-with-the-form-api

Leave a comment