_form_element_triggered_scripted_submission

  1. drupal
    1. 7
Versions
7 _form_element_triggered_scripted_submission($element, &$form_state)

Helper function to handle the convoluted logic of button click detection.

This detects button or non-button controls that trigger a form submission via Ajax or some other scriptable environment. These environments can set the special input key '_triggering_element_name' to identify the triggering element. If the name alone doesn't identify the element uniquely, the input key '_triggering_element_value' may also be set to require a match on element value. An example where this is needed is if there are several buttons all named 'op', and only differing in their value.

Related topics

▾ 1 function calls _form_element_triggered_scripted_submission()

_form_builder_handle_input_element in drupal/includes/form.inc
Populate the #value and #name properties of input elements so they can be processed and rendered.

Code

drupal/includes/form.inc, line 2002

<?php
function _form_element_triggered_scripted_submission($element, &$form_state) {
  if (!empty($form_state['input']['_triggering_element_name']) && $element['#name'] == $form_state['input']['_triggering_element_name']) {
    if (empty($form_state['input']['_triggering_element_value']) || $form_state['input']['_triggering_element_value'] == $element['#value']) {
      return TRUE;
    }
  }
  return FALSE;
}
?>