You are here

public function ManageForm::buildForm in Form Defaults 8

Form management form used for inspecting and resetting forms.

Return value

Form

Overrides FormInterface::buildForm

File

src/Form/ManageForm.php, line 20

Class

ManageForm

Namespace

Drupal\Formdefaults\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $search_str = @$_SESSION['formdefaults_search'];
  $form['search_str'] = array(
    '#type' => 'textfield',
    '#default_value' => $search_str,
    '#description' => t('Search all forms that have a formid (name) containing the word you specify.'),
  );
  $form['search'] = array(
    '#type' => 'submit',
    '#value' => 'Search',
    '#size' => 10,
  );
  $form['results'] = array(
    '#type' => 'fieldset',
    '#title' => 'Overridden Forms',
    '#tree' => TRUE,
  );
  $helper = new FormDefaultsHelper();
  $form_list = $helper
    ->search($search_str);
  $list = array();
  foreach ($form_list as $form_key => $f) {
    $list[$form_key] = Link::createFromRoute(t($form_key), 'formdefaults.edit_w_formid', [
      'formid' => $form_key,
    ]);
  }
  $form['results']['reset_forms'] = array(
    '#type' => 'checkboxes',
    '#options' => $list,
  );
  $form['results']['reset'] = array(
    '#type' => 'submit',
    '#value' => 'Reset Selected',
  );
  return $form;
}