You are here

public function FulfillmentMethodForm::form in Ubercart 8.4

Gets the actual form array to be built.

Overrides EntityForm::form

See also

\Drupal\Core\Entity\EntityForm::processForm()

\Drupal\Core\Entity\EntityForm::afterBuild()

File

shipping/uc_fulfillment/src/Form/FulfillmentMethodForm.php, line 57

Class

FulfillmentMethodForm
Builds the form to edit fulfillment method entities.

Namespace

Drupal\uc_fulfillment\Form

Code

public function form(array $form, FormStateInterface $form_state) {
  $form = parent::form($form, $form_state);
  $definition = $this->plugin
    ->getPluginDefinition();
  $form['type'] = [
    '#type' => 'item',
    '#title' => $this
      ->t('Type'),
    '#markup' => $definition['admin_label'],
  ];
  $form['label'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Label'),
    '#maxlength' => 255,
    '#default_value' => $this->entity
      ->label(),
    '#description' => $this
      ->t('The name shown to the customer when they choose a fulfillment method at checkout.'),
    '#required' => TRUE,
  ];
  $form['id'] = [
    '#type' => 'machine_name',
    '#default_value' => $this->entity
      ->id(),
    '#maxlength' => 32,
    '#machine_name' => [
      'exists' => '\\Drupal\\uc_fulfillment\\Entity\\FulfillmentMethod::load',
    ],
    '#disabled' => !$this->entity
      ->isNew(),
  ];
  $form['settings'] = $this->plugin
    ->buildConfigurationForm([], $form_state);
  $form['settings']['#tree'] = TRUE;
  return $form;
}