Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I have enabled/uncomented the following code in template.php of my subtheme:
function mopfoundationfive_form_alter(&$form, &$form_state, $form_id) {
// // Sexy submit buttons
if (!empty($form['actions']) && !empty($form['actions']['submit'])) {
$classes = (is_array($form['actions']['submit']['#attributes']['class']))
? $form['actions']['submit']['#attributes']['class']
: array();
$classes = array_merge($classes, array('primary', 'small', 'button', 'radius'));
$form['actions']['submit']['#attributes']['class'] = $classes;
}
I have just changed the classes in line 7 above. When the above code is rendered in browser the primary coloured small button does not show up. The firebug shows the following html:
<button type="submit" value="Submit" name="op" id="edit-submit" class="secondary button radius primary small button radius form-submit">Submit</button>
the classes secondary button radius should not show up as they were the default classes form the uncommented version of the code.
Comments
Comment #1
kevinquillen CreditAttribution: kevinquillen commentedComment #2
beachston CreditAttribution: beachston commentedI also encountered this problem. If you look in the preprocess function above the form alter in your template.php, you will see where that extra 'secondary' and 'button' classes are being added:
Commenting out this function removed the extra classes for me.
Comment #3
kevinquillen CreditAttribution: kevinquillen commentedYes, it is a little confusing. The classes are applied out of the box for those, so no further action is necessary.
The button classes are added in by default from the parent theme in form.inc. The boilerplate code is commented out, indicating that to add it in, you uncomment it, which is not the case.
I will remove the boilerplate code because it really isn't necessary to have until you're ready to override. It just makes it confusing.
Comment #4
kevinquillen CreditAttribution: kevinquillen commented