You are here

public function AjaxPriceTestForm::ajaxSubmit in Commerce Core 8.2

An AJAX callback for the form.

Parameters

array $form: The form array.

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

Return value

array Some markup.

File

modules/price/tests/modules/commerce_price_test/src/Form/AjaxPriceTestForm.php, line 73

Class

AjaxPriceTestForm
A form for testing AJAX on commerce_price elements.

Namespace

Drupal\commerce_price_test\Form

Code

public function ajaxSubmit(array $form, FormStateInterface $form_state) {
  return [
    '#prefix' => '<div id="ajax-replace">',
    '#markup' => 'AJAX successful: ' . $form_state
      ->getTriggeringElement()['#name'],
    '#suffix' => '</div>',
  ];
}