You are here

public static function CommerceElementTrait::executeElementSubmitHandlers in Commerce Core 8.2

Submits elements by calling their #commerce_element_submit callbacks.

Form API has no #element_submit, requiring us to simulate it by running the #commerce_element_submit handlers either in the last step of validation, or the first step of submission. In this case it's the last step of validation, allowing thrown exceptions to be converted into form errors.

Parameters

array &$form: The form.

\Drupal\Core\Form\FormStateInterface $form_state: The form state.

File

src/Element/CommerceElementTrait.php, line 84

Class

CommerceElementTrait
Allows form elements to use #commerce_element_submit.

Namespace

Drupal\commerce\Element

Code

public static function executeElementSubmitHandlers(array &$form, FormStateInterface $form_state) {
  if (self::shouldExecuteElementSubmit($form_state)) {
    self::doExecuteSubmitHandlers($form, $form_state);
  }
}