function views_ui_form_button_was_clicked

3.x admin.inc views_ui_form_button_was_clicked($element, &$form_state)

#process callback for a button; determines if a button is the form's triggering element.

The Form API has logic to determine the form's triggering element based on the data in $_POST. However, it only checks buttons based on a single #value per button. This function may be added to a button's #process callbacks to extend button click detection to support multiple #values per button. If the data in $_POST matches any value in the button's #values array, then the button is detected as having been clicked. This can be used when the value (label) of the same logical button may be different based on context (e.g., "Apply" vs. "Apply and continue").

See also

_form_builder_handle_input_element()

_form_button_was_clicked()

2 string references to 'views_ui_form_button_was_clicked'
views_ui_render_display_top in includes/admin.inc
Render the top of the display so it can be updated during ajax operations.
views_ui_standard_form_buttons in includes/admin.inc
Provide a standard set of Apply/Cancel/OK buttons for the forms. Also provide a hidden op operator because the forms plugin doesn't seem to properly provide which button was clicked.

File

includes/admin.inc, line 5366
Provides the Views' administrative interface.

Code

function views_ui_form_button_was_clicked($element, &$form_state) {
  $process_input = empty($element['#disabled']) && ($form_state['programmed'] || ($form_state['process_input'] && (!isset($element['#access']) || $element['#access'])));
  if ($process_input && !isset($form_state['triggering_element']) && isset($element['#button_type']) && isset($form_state['input'][$element['#name']]) && isset($element['#values']) && in_array($form_state['input'][$element['#name']], $element['#values'], TRUE)) {
    $form_state['triggering_element'] = $element;
  }
  return $element;
}