You are here

function _hide_submit_add_exclude_class in Hide submit button 6

Same name and namespace in other branches
  1. 5 hide_submit.module \_hide_submit_add_exclude_class()
  2. 7 hide_submit.module \_hide_submit_add_exclude_class()

A recursive function to add class to all excluded submit buttons

1 call to _hide_submit_add_exclude_class()
hide_submit_form_alter in ./hide_submit.module
Implementation of hook_form_alter

File

./hide_submit.module, line 211
Hide the submit button after clicked to prevent/reduce duplicate postings.

Code

function _hide_submit_add_exclude_class(&$elements) {

  // Recurse through all children.
  foreach (element_children($elements) as $key) {
    if (isset($elements[$key]) && $elements[$key]) {
      _hide_submit_add_exclude_class($elements[$key]);
    }
  }

  // Add class to submit buttons
  if (isset($elements['#type']) && $elements['#type'] == 'submit') {
    $elements['#attributes']['class'] = empty($elements['#attributes']['class']) ? HIDE_SUBMIT_EXCLUDE_CLASS : $elements['#attributes']['class'] . ' ' . HIDE_SUBMIT_EXCLUDE_CLASS;
  }
}