You are here

function panopoly_magic_autosubmit_configure in Panopoly Magic 7

Recursively parse form elements to add special autosubmit handling on a per field-type basis.

3 calls to panopoly_magic_autosubmit_configure()
panopoly_magic_form_ctools_entity_field_content_type_formatter_options_alter in ./panopoly_magic.module
Implementation of hook_form_FORM_ID_alter()
panopoly_magic_form_fieldable_panels_panes_fieldable_panels_pane_content_type_edit_form_alter in ./panopoly_magic.module
Implementation of hook_form_FORM_ID_alter()
panopoly_magic_form_views_content_views_panes_content_type_edit_form_alter in ./panopoly_magic.module
Implementation of hook_form_FORM_ID_alter()

File

./panopoly_magic.module, line 817

Code

function panopoly_magic_autosubmit_configure(&$element) {
  if (!empty($element['#type'])) {
    switch ($element['#type']) {
      case 'textfield':

        // Special handling for autosubmit.
        if (!empty($element['#autocomplete_path'])) {
          $element['#attributes']['class'][] = 'ctools-auto-submit-exclude panopoly-autocomplete-autosubmit';
        }
        else {
          $element['#attributes']['class'][] = 'ctools-auto-submit-exclude panopoly-textfield-autosubmit';
        }
        break;
      case 'text_format':
        $element['#attributes']['class'][] = 'ctools-auto-submit-exclude panopoly-textarea-autosubmit';
        break;
      default:
        break;
    }
  }
  $children = element_children($element);
  if (!empty($children) && is_array($children)) {
    foreach ($children as $child) {
      panopoly_magic_autosubmit_configure($element[$child]);
    }
  }
}