You are here

public function ProductBundleItemTypeForm::form in Commerce Product Bundle 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

src/Form/ProductBundleItemTypeForm.php, line 19

Class

ProductBundleItemTypeForm
Provides the product bundle item type form.

Namespace

Drupal\commerce_product_bundle\Form

Code

public function form(array $form, FormStateInterface $form_state) {
  $form = parent::form($form, $form_state);
  $product_bundle_item_type = $this->entity;
  $form['label'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Label'),
    '#maxlength' => 255,
    '#default_value' => $product_bundle_item_type
      ->label(),
    '#description' => $this
      ->t("Label for the product bundle item type."),
    '#required' => TRUE,
  ];
  $form['id'] = [
    '#type' => 'machine_name',
    '#default_value' => $product_bundle_item_type
      ->id(),
    '#machine_name' => [
      'exists' => '\\Drupal\\commerce_product_bundle\\Entity\\ProductBundleItemType::load',
    ],
    '#maxlength' => EntityTypeInterface::BUNDLE_MAX_LENGTH,
    '#disabled' => !$product_bundle_item_type
      ->isNew(),
  ];
  $form['description'] = [
    '#type' => 'textarea',
    '#title' => $this
      ->t('Description'),
    '#description' => $this
      ->t('This text will be displayed on the <em>Add product bundle item</em> page.'),
    '#default_value' => $product_bundle_item_type
      ->getDescription(),
  ];
  return $form;
}