public function ConfigsList::buildForm in Devel 8
Same name and namespace in other branches
- 8.3 src/Form/ConfigsList.php \Drupal\devel\Form\ConfigsList::buildForm()
- 8.2 src/Form/ConfigsList.php \Drupal\devel\Form\ConfigsList::buildForm()
- 4.x src/Form/ConfigsList.php \Drupal\devel\Form\ConfigsList::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
- src/
Form/ ConfigsList.php, line 25
Class
- ConfigsList
- Form that displays all the config variables to edit them.
Namespace
Drupal\devel\FormCode
public function buildForm(array $form, FormStateInterface $form_state, $filter = '') {
$form['filter'] = array(
'#type' => 'details',
'#title' => t('Filter variables'),
'#attributes' => array(
'class' => array(
'container-inline',
),
),
'#open' => isset($filter) && trim($filter) != '',
);
$form['filter']['name'] = array(
'#type' => 'textfield',
'#title' => $this
->t('Variable name'),
'#title_display' => 'invisible',
'#default_value' => $filter,
);
$form['filter']['actions'] = [
'#type' => 'actions',
];
$form['filter']['actions']['show'] = [
'#type' => 'submit',
'#value' => $this
->t('Filter'),
];
$header = array(
'name' => array(
'data' => $this
->t('Name'),
),
'edit' => array(
'data' => $this
->t('Operations'),
),
);
$rows = array();
$destination = $this
->getDestinationArray();
// List all the variables filtered if any filter was provided.
$names = $this
->configFactory()
->listAll($filter);
foreach ($names as $config_name) {
$operations['edit'] = array(
'title' => $this
->t('Edit'),
'url' => Url::fromRoute('devel.config_edit', array(
'config_name' => $config_name,
)),
'query' => $destination,
);
$rows[] = array(
'name' => $config_name,
'operation' => array(
'data' => array(
'#type' => 'operations',
'#links' => $operations,
),
),
);
}
$form['variables'] = array(
'#type' => 'table',
'#header' => $header,
'#rows' => $rows,
'#empty' => $this
->t('No variables found'),
);
return $form;
}