public DblogFilterForm::buildForm(array $form, FormStateInterface $form_state)
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
- core/modules/dblog/src/Form/DblogFilterForm.php, line 23
Class
- DblogFilterForm
- Provides the database logging filter form.
Namespace
Drupal\dblog\Form
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | public function buildForm( array $form , FormStateInterface $form_state ) { $filters = dblog_filters(); $form [ 'filters' ] = array ( '#type' => 'details' , '#title' => $this ->t( 'Filter log messages' ), '#open' => TRUE, ); foreach ( $filters as $key => $filter ) { $form [ 'filters' ][ 'status' ][ $key ] = array ( '#title' => $filter [ 'title' ], '#type' => 'select' , '#multiple' => TRUE, '#size' => 8, '#options' => $filter [ 'options' ], ); if (! empty ( $_SESSION [ 'dblog_overview_filter' ][ $key ])) { $form [ 'filters' ][ 'status' ][ $key ][ '#default_value' ] = $_SESSION [ 'dblog_overview_filter' ][ $key ]; } } $form [ 'filters' ][ 'actions' ] = array ( '#type' => 'actions' , '#attributes' => array ( 'class' => array ( 'container-inline' )), ); $form [ 'filters' ][ 'actions' ][ 'submit' ] = array ( '#type' => 'submit' , '#value' => $this ->t( 'Filter' ), ); if (! empty ( $_SESSION [ 'dblog_overview_filter' ])) { $form [ 'filters' ][ 'actions' ][ 'reset' ] = array ( '#type' => 'submit' , '#value' => $this ->t( 'Reset' ), '#limit_validation_errors' => array (), '#submit' => array ( '::resetForm' ), ); } return $form ; } |
Please login to continue.