public function GdprFieldFilterForm::buildForm in General Data Protection Regulation 8
Same name and namespace in other branches
- 8.2 modules/gdpr_fields/src/Form/GdprFieldFilterForm.php \Drupal\gdpr_fields\Form\GdprFieldFilterForm::buildForm()
- 3.0.x modules/gdpr_fields/src/Form/GdprFieldFilterForm.php \Drupal\gdpr_fields\Form\GdprFieldFilterForm::buildForm()
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/
gdpr_fields/ src/ Form/ GdprFieldFilterForm.php, line 54
Class
- GdprFieldFilterForm
- Filter form for GDPR field list page.
Namespace
Drupal\gdpr_fields\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$filters = self::getFilters($this
->getRequest());
// @todo Add classes and styling to move filters inline.
$form['container'] = [];
$entities = [];
foreach ($this->entityTypeManager
->getDefinitions() as $key => $definition) {
// Exclude anything not fieldable (ie config entities)
if ($definition
->entityClassImplements(FieldableEntityInterface::class)) {
$entities[$key] = $definition
->getLabel();
}
}
$form['container']['search'] = [
'#type' => 'textfield',
'#title' => $this
->t('Search'),
'#default_value' => $filters['search'],
];
$form['container']['entity_type'] = [
'#type' => 'select',
'#title' => $this
->t('Entity Type'),
'#options' => $entities,
'#multiple' => TRUE,
'#default_value' => $filters['entity_type'],
];
$form['container']['rta'] = [
'#type' => 'select',
'#title' => $this
->t('Right to access'),
'#options' => [
'0' => 'Not configured',
] + GdprField::rtaOptions(),
'#multiple' => TRUE,
'#default_value' => $filters['rta'],
];
$form['container']['rtf'] = [
'#type' => 'select',
'#title' => $this
->t('Right to be forgotten'),
'#options' => [
'0' => 'Not configured',
] + GdprField::rtfOptions(),
'#multiple' => TRUE,
'#default_value' => $filters['rtf'],
];
$form['container']['empty'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Filter out Entities where all fields are not configured'),
'#default_value' => $filters['empty'],
];
$form['container']['submit'] = [
'#type' => 'submit',
'#value' => $this
->t('Apply'),
'#button_type' => 'primary',
];
$form['container']['reset'] = [
'#type' => 'submit',
'#value' => $this
->t('Reset'),
'#submit' => [
[
$this,
'resetForm',
],
],
'#limit_validation_errors' => [],
];
return $form;
}