views_ui_form_button_was_clicked($element, FormStateInterface $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()
File
- core/modules/views_ui/admin.inc, line 315
- Provides the Views' administrative interface.
Code
function views_ui_form_button_was_clicked($element, FormStateInterface $form_state) { $user_input = $form_state->getUserInput(); $process_input = empty($element['#disabled']) && ($form_state->isProgrammed() || ($form_state->isProcessingInput() && (!isset($element['#access']) || $element['#access']))); if ($process_input && !$form_state->getTriggeringElement() && !empty($element['#is_button']) && isset($user_input[$element['#name']]) && isset($element['#values']) && in_array($user_input[$element['#name']], array_map('strval', $element['#values']), TRUE)) { $form_state->setTriggeringElement($element); } return $element; }
Please login to continue.