public function LogTypeForm::form in Log entity 2.x
Same name and namespace in other branches
- 8 src/Form/LogTypeForm.php \Drupal\log\Form\LogTypeForm::form()
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/ LogTypeForm.php, line 58
Class
- LogTypeForm
- Form controller for Log type entities.
Namespace
Drupal\log\FormCode
public function form(array $form, FormStateInterface $form_state) {
$form = parent::form($form, $form_state);
$log_type = $this->entity;
$form['label'] = [
'#type' => 'textfield',
'#title' => $this
->t('Label'),
'#maxlength' => 255,
'#default_value' => $log_type
->label(),
'#description' => $this
->t('Label for the Log type.'),
'#required' => TRUE,
];
$form['id'] = [
'#type' => 'machine_name',
'#default_value' => $log_type
->id(),
'#machine_name' => [
'exists' => '\\Drupal\\log\\Entity\\LogType::load',
],
'#disabled' => !$log_type
->isNew(),
];
$form['description'] = [
'#type' => 'textarea',
'#title' => $this
->t('Description'),
'#default_value' => $log_type
->getDescription(),
];
$form['name_pattern'] = [
'#type' => 'textfield',
'#title' => $this
->t('Name pattern'),
'#maxlength' => 255,
'#default_value' => $log_type
->getNamePattern() ?: 'Log [log:id]',
'#description' => $this
->t('When filled in, log names of this type will be auto-generated using this naming pattern. Leave empty for not auto generating log names.'),
'#required' => TRUE,
];
$form['token_help'] = [
'#theme' => 'token_tree_link',
'#token_types' => [
'log',
],
];
$form['workflow'] = [
'#type' => 'select',
'#title' => $this
->t('Workflow'),
'#options' => $this->workflowManager
->getGroupedLabels('log'),
'#default_value' => $log_type
->getWorkflowId(),
'#description' => $this
->t('Used by all logs of this type.'),
];
$form['new_revision'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Create new revision'),
'#default_value' => $log_type
->shouldCreateNewRevision(),
];
return $form;
}