You are here

public function OrderStatusAddForm::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 FormInterface::buildForm

File

uc_order/src/Form/OrderStatusAddForm.php, line 25

Class

OrderStatusAddForm
Presents the form to create a custom order status.

Namespace

Drupal\uc_order\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $form['id'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Order status ID'),
    '#description' => $this
      ->t('Must be a unique ID with no spaces.'),
    '#size' => 32,
    '#maxlength' => 32,
    '#required' => TRUE,
  ];
  $form['name'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Title'),
    '#description' => $this
      ->t('The order status title displayed to users.'),
    '#size' => 32,
    '#maxlength' => 48,
    '#required' => TRUE,
  ];
  $form['state'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Order state'),
    '#description' => $this
      ->t('Set which order state this status is for.'),
    '#options' => uc_order_state_options_list(),
    '#default_value' => 'post_checkout',
  ];
  $form['weight'] = [
    '#type' => 'weight',
    '#title' => $this
      ->t('List position'),
    '#delta' => 20,
    '#default_value' => 0,
  ];
  $form['actions'] = [
    '#type' => 'actions',
  ];
  $form['actions']['create'] = [
    '#type' => 'submit',
    '#value' => $this
      ->t('Create'),
  ];
  $form['actions']['cancel'] = [
    '#type' => 'link',
    '#title' => $this
      ->t('Cancel'),
    '#url' => Url::fromRoute('uc_order.workflow'),
  ];
  return $form;
}