public function PaymentAddForm::buildForm in Commerce Core 8.2
Form constructor.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The form structure.
Overrides FormInterface::buildForm
File
- modules/
payment/ src/ Form/ PaymentAddForm.php, line 101
Class
- PaymentAddForm
- Provides the payment add form.
Namespace
Drupal\commerce_payment\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
// Prepare the form for ajax.
$form['#wrapper_id'] = Html::getUniqueId('payment-add-form-wrapper');
$form['#prefix'] = '<div id="' . $form['#wrapper_id'] . '">';
$form['#suffix'] = '</div>';
$form['#tree'] = TRUE;
$step = $form_state
->get('step');
$step = $step ?: 'payment_gateway';
$form_state
->set('step', $step);
if ($step == 'payment_gateway') {
$form = $this
->buildPaymentGatewayForm($form, $form_state);
}
elseif ($step == 'payment') {
$form = $this
->buildPaymentForm($form, $form_state);
}
return $form;
}