You are here

public function StockLocationTypeForm::form in Commerce Stock 8

Gets the actual form array to be built.

Overrides EntityForm::form

See also

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

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

File

modules/local_storage/src/Form/StockLocationTypeForm.php, line 18

Class

StockLocationTypeForm
Class StockLocationTypeForm.

Namespace

Drupal\commerce_stock_local\Form

Code

public function form(array $form, FormStateInterface $form_state) {
  $form = parent::form($form, $form_state);
  $commerce_stock_location_type = $this->entity;
  $form['label'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Label'),
    '#maxlength' => 255,
    '#default_value' => $commerce_stock_location_type
      ->label(),
    '#description' => $this
      ->t("Label for the stock location type."),
    '#required' => TRUE,
  ];
  $form['id'] = [
    '#type' => 'machine_name',
    '#default_value' => $commerce_stock_location_type
      ->id(),
    '#machine_name' => [
      'exists' => '\\Drupal\\commerce_stock_local\\Entity\\StockLocationType::load',
    ],
    '#disabled' => !$commerce_stock_location_type
      ->isNew(),
  ];

  /* You will need additional form elements for your custom properties. */
  return $form;
}