public function PaymentMethodListBuilder::buildForm in Ubercart 8.4
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 DraggableListBuilder::buildForm
File
- payment/uc_payment/ src/ PaymentMethodListBuilder.php, line 105 
Class
- PaymentMethodListBuilder
- Defines a class to build a listing of payment method configuration entities.
Namespace
Drupal\uc_paymentCode
public function buildForm(array $form, FormStateInterface $form_state) {
  $options = array_map(function ($definition) {
    return $definition['name'];
  }, array_filter($this->paymentMethodManager
    ->getDefinitions(), function ($definition) {
    return !$definition['no_ui'];
  }));
  if ($options) {
    uasort($options, 'strnatcasecmp');
    $form['add'] = [
      '#type' => 'details',
      '#title' => $this
        ->t('Add payment method'),
      '#open' => TRUE,
      '#attributes' => [
        'class' => [
          'container-inline',
        ],
      ],
    ];
    $form['add']['payment_method_type'] = [
      '#type' => 'select',
      '#title' => $this
        ->t('Type'),
      '#empty_option' => $this
        ->t('- Choose -'),
      '#options' => $options,
    ];
    $form['add']['submit'] = [
      '#type' => 'submit',
      '#value' => $this
        ->t('Add payment method'),
      '#validate' => [
        '::validateAddPaymentMethod',
      ],
      '#submit' => [
        '::submitAddPaymentMethod',
      ],
      '#limit_validation_errors' => [
        [
          'payment_method_type',
        ],
      ],
    ];
  }
  $form = parent::buildForm($form, $form_state);
  $form[$this->entitiesKey]['#empty'] = $this
    ->t('No payment methods have been configured.');
  $form['actions']['#type'] = 'actions';
  $form['actions']['submit'] = [
    '#type' => 'submit',
    '#value' => $this
      ->t('Save configuration'),
    '#button_type' => 'primary',
  ];
  return $form;
}