public function KanbanFilterForm::buildForm in Content Planner 8
Form constructor.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The form structure.
Overrides FormInterface::buildForm
File
- modules/
content_kanban/ src/ Form/ KanbanFilterForm.php, line 70
Class
- KanbanFilterForm
- KanbanFilterForm class.
Namespace
Drupal\content_kanban\FormCode
public function buildForm(array $form, FormStateInterface $form_state, $params = []) {
$this->formParams = $params;
$form_state
->setMethod('GET');
$form['filters'] = [
'#type' => 'fieldset',
'#title' => $this
->t('Filters'),
'#collapsible' => FALSE,
'#collapsed' => FALSE,
'#attributes' => [
'class' => [
'form--inline',
],
],
];
// User ID.
$form['filters']['filter_uid'] = [
'#type' => 'select',
'#title' => $this
->t('User'),
'#options' => $this
->getUserOptions(),
'#required' => FALSE,
'#empty_value' => '',
'#empty_option' => $this
->t('- Select -'),
'#default_value' => self::getUserIdFilter(),
];
// User ID.
$form['filters']['filter_state'] = [
'#type' => 'select',
'#title' => $this
->t('States'),
'#options' => $this
->getStateOptions(),
'#required' => FALSE,
'#empty_value' => '',
'#empty_option' => $this
->t('All'),
'#default_value' => self::getStateFilter(),
];
$form['filters']['filter_date_range'] = [
'#type' => 'select',
'#title' => $this
->t('Date range'),
'#options' => self::getDateRangeOptions(),
'#required' => FALSE,
'#empty_value' => '',
'#empty_option' => $this
->t('All'),
'#default_value' => self::getDateRangeFilter(),
];
$form['filters']['filter_content_type'] = [
'#type' => 'select',
'#title' => $this
->t('Content type'),
'#options' => self::getContentTypeOptions($params['workflow_id']),
'#required' => FALSE,
'#empty_value' => '',
'#empty_option' => $this
->t('All'),
'#default_value' => self::getContentTypeFilter(),
'#required' => FALSE,
];
$form['filters']['search'] = [
'#type' => 'textfield',
'#title' => $this
->t('Instant Search'),
'#required' => FALSE,
];
// Actions.
$form['filters']['actions'] = [
'#type' => 'actions',
];
// Submit button.
$form['filters']['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this
->t('Search'),
];
$form['filters']['actions']['reset'] = [
'#markup' => Link::createFromRoute($this
->t('Reset'), 'content_kanban.kanban')
->toString(),
];
return $form;
}