function views_ui_add_limited_validation in Views (for Drupal 7) 8.3
Same name and namespace in other branches
- 7.3 includes/admin.inc \views_ui_add_limited_validation()
Processes a non-JavaScript fallback submit button to limit its validation errors.
1 string reference to 'views_ui_add_limited_validation'
- views_ui_add_ajax_trigger in views_ui/
admin.inc - Converts a form element in the add view wizard to be AJAX-enabled.
File
- views_ui/
admin.inc, line 223 - Provides the Views' administrative interface.
Code
function views_ui_add_limited_validation($element, &$form_state) {
// Retrieve the AJAX triggering element so we can determine its parents. (We
// know it's at the same level of the complete form array as the submit
// button, so all we have to do to find it is swap out the submit button's
// last array parent.)
$array_parents = $element['#array_parents'];
array_pop($array_parents);
$array_parents[] = $element['#views_ui_ajax_data']['trigger_key'];
$ajax_triggering_element = drupal_array_get_nested_value($form_state['complete_form'], $array_parents);
// Limit this button's validation to the AJAX triggering element, so it can
// update the form for that change without requiring that the rest of the
// form be filled out properly yet.
$element['#limit_validation_errors'] = array(
$ajax_triggering_element['#parents'],
);
// If we are in the process of a form submission and this is the button that
// was clicked, the form API workflow in form_builder() will have already
// copied it to $form_state['triggering_element'] before our #process
// function is run. So we need to make the same modifications in $form_state
// as we did to the element itself, to ensure that #limit_validation_errors
// will actually be set in the correct place.
if (!empty($form_state['triggering_element'])) {
$clicked_button =& $form_state['triggering_element'];
if ($clicked_button['#name'] == $element['#name'] && $clicked_button['#value'] == $element['#value']) {
$clicked_button['#limit_validation_errors'] = $element['#limit_validation_errors'];
}
}
return $element;
}