You are here

public function AssetTypeForm::form in farmOS 2.x

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/core/asset/src/Form/AssetTypeForm.php, line 46

Class

AssetTypeForm
Form controller for asset type entities.

Namespace

Drupal\asset\Form

Code

public function form(array $form, FormStateInterface $form_state) {
  $form = parent::form($form, $form_state);
  $asset_type = $this->entity;
  $form['label'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Label'),
    '#maxlength' => 255,
    '#default_value' => $asset_type
      ->label(),
    '#description' => $this
      ->t('Label for the asset type.'),
    '#required' => TRUE,
  ];
  $form['id'] = [
    '#type' => 'machine_name',
    '#default_value' => $asset_type
      ->id(),
    '#machine_name' => [
      'exists' => '\\Drupal\\asset\\Entity\\AssetType::load',
    ],
    '#disabled' => !$asset_type
      ->isNew(),
  ];
  $form['description'] = [
    '#type' => 'textarea',
    '#title' => $this
      ->t('Description'),
    '#default_value' => $asset_type
      ->getDescription(),
  ];
  $form['workflow'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Workflow'),
    '#options' => $this->workflowManager
      ->getGroupedLabels('asset'),
    '#default_value' => $asset_type
      ->getWorkflowId(),
    '#description' => $this
      ->t('Used by all assets of this type.'),
  ];
  $form['new_revision'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Create new revision'),
    '#default_value' => $asset_type
      ->shouldCreateNewRevision(),
  ];
  return $form;
}