public static function CommerceElementTrait::attachElementSubmit in Commerce Core 8.2
Attaches the #commerce_element_submit functionality.
Parameters
array $element: The form element being processed.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
array $complete_form: The complete form structure.
Return value
array The processed form element.
File
- src/
Element/ CommerceElementTrait.php, line 37
Class
- CommerceElementTrait
- Allows form elements to use #commerce_element_submit.
Namespace
Drupal\commerce\ElementCode
public static function attachElementSubmit(array $element, FormStateInterface $form_state, array &$complete_form) {
if (isset($complete_form['#commerce_element_submit_attached'])) {
return $element;
}
// The #validate callbacks of the complete form run last.
// That allows executeElementSubmitHandlers() to be completely certain that
// the form has passed validation before proceeding.
$complete_form['#validate'][] = [
get_class(),
'executeElementSubmitHandlers',
];
$complete_form['#commerce_element_submit_attached'] = TRUE;
return $element;
}