public function PriceListTypeForm::form in Commerce Pricelist 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/ PriceListTypeForm.php, line 52
Class
- PriceListTypeForm
- Class PriceListTypeForm.
Namespace
Drupal\commerce_pricelist\FormCode
public function form(array $form, FormStateInterface $form_state) {
$form = parent::form($form, $form_state);
/** @var \Drupal\commerce_pricelist\Entity\PriceListTypeInterface $price_list_type */
$price_list_type = $this->entity;
$form['label'] = [
'#type' => 'textfield',
'#title' => $this
->t('Label'),
'#maxlength' => 255,
'#default_value' => $price_list_type
->label(),
'#description' => $this
->t("Label for the Price list type."),
'#required' => TRUE,
];
$form['id'] = [
'#type' => 'machine_name',
'#default_value' => $price_list_type
->id(),
'#machine_name' => [
'exists' => '\\Drupal\\commerce_pricelist\\Entity\\PriceListType::load',
],
'#disabled' => !$price_list_type
->isNew(),
];
$form['description'] = [
'#type' => 'textfield',
'#title' => $this
->t('Description'),
'#default_value' => $price_list_type
->getDescription(),
];
$form = $this
->buildTraitForm($form, $form_state);
/* You will need additional form elements for your custom properties. */
return $this
->protectBundleIdElement($form);
}