You are here

public function PaymentLineItemPaymentBasicFormElements::buildForm in Payment 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_test/src/PaymentLineItemPaymentBasicFormElements.php, line 30

Class

PaymentLineItemPaymentBasicFormElements

Namespace

Drupal\payment_test

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  if ($form_state
    ->has('payment_line_item')) {
    $line_item = $form_state
      ->get('payment_line_item');
  }
  else {
    $line_item = Payment::lineItemManager()
      ->createInstance('payment_basic');
    $form_state
      ->set('payment_line_item', $line_item);
  }
  $form['line_item'] = $line_item
    ->buildConfigurationForm([], $form_state);
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Submit'),
  );
  return $form;
}