public function CustomFilterForm::form in Custom filter 8
Same name and namespace in other branches
- 2.0.x src/Form/CustomFilterForm.php \Drupal\customfilter\Form\CustomFilterForm::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/ CustomFilterForm.php, line 17
Class
Namespace
Drupal\customfilter\FormCode
public function form(array $form, FormStateInterface $form_state) {
$form = parent::form($form, $form_state);
/** @var \Drupal\customfilter\Entity\CustomFilter $filter */
$filter = $this->entity;
$form['name'] = array(
'#type' => 'textfield',
'#title' => $this
->t('Label'),
'#maxlength' => 255,
'#default_value' => $filter
->label(),
'#description' => $this
->t("Label for the filter."),
'#required' => TRUE,
);
$form['id'] = array(
'#type' => 'machine_name',
'#default_value' => $filter
->id(),
'#description' => $this
->t('The machine-readable name of the filter. This name
must contain only lowercase letters, numbers, and underscores and
can not be changed latter'),
'#machine_name' => array(
'exists' => [
CustomFilter::class,
'load',
],
'source' => [
'name',
],
),
'#disabled' => !$filter
->isNew(),
'#required' => TRUE,
);
$form['cache'] = array(
'#type' => 'checkbox',
'#title' => $this
->t('Cache'),
'#description' => $this
->t('If checked, the content will be cached.'),
'#default_value' => $filter
->getCache(),
);
$form['description'] = array(
'#type' => 'textarea',
'#title' => $this
->t('Description'),
'#description' => $this
->t('A description of the purpose of this filter.'),
'#default_value' => $filter
->getDescription(),
);
$form['shorttip'] = array(
'#type' => 'textarea',
'#title' => $this
->t('Tips (short)'),
'#default_value' => $filter
->getShorttip(),
'#rows' => 5,
'#description' => $this
->t('This tip will be show in edit content/comments forms.'),
);
$form['longtip'] = array(
'#type' => 'textarea',
'#title' => $this
->t('Tips (full)'),
'#default_value' => $filter
->getLongtip(),
'#rows' => 20,
);
$form['rules'] = array(
'#type' => 'value',
'#value' => $filter->rules,
);
return $form;
}