3 namespace Drupal\devel\Form;
5 use Drupal\Component\Utility\Html;
6 use Drupal\Core\Form\FormBase;
7 use Drupal\Core\Form\FormStateInterface;
11 * Form that displays all the config variables to edit them.
13 class ConfigsList extends FormBase {
18 public function getFormId() {
19 return 'devel_config_system_form';
25 public function buildForm(array $form, FormStateInterface $form_state, $filter = '') {
26 $form['filter'] = array(
28 '#title' => t('Filter variables'),
29 '#attributes' => array('class' => array('container-inline')),
30 '#open' => isset($filter) && trim($filter) != '',
32 $form['filter']['name'] = array(
33 '#type' => 'textfield',
34 '#title' => $this->t('Variable name'),
35 '#title_display' => 'invisible',
36 '#default_value' => $filter,
38 $form['filter']['show'] = array(
40 '#value' => $this->t('Filter'),
44 'name' => array('data' => $this->t('Name')),
45 'edit' => array('data' => $this->t('Operations')),
50 $destination = $this->getDestinationArray();
52 // List all the variables filtered if any filter was provided.
53 $names = $this->configFactory()->listAll($filter);
55 foreach ($names as $config_name) {
56 $operations['edit'] = array(
57 'title' => $this->t('Edit'),
58 'url' => Url::fromRoute('devel.config_edit', array('config_name' => $config_name)),
59 'query' => $destination
62 'name' => $config_name,
63 'operation' => array('data' => array('#type' => 'operations', '#links' => $operations)),
67 $form['variables'] = array(
71 '#empty' => $this->t('No variables found')
80 public function submitForm(array &$form, FormStateInterface $form_state) {
81 $filter = $form_state->getValue('name');
82 $form_state->setRedirectUrl(Url::FromRoute('devel.configs_list', array('filter' => Html::escape($filter))));