Fz152SettingsForms.php in FZ152 8
File
src/Form/Fz152SettingsForms.php
View source
<?php
namespace Drupal\fz152\Form;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;
class Fz152SettingsForms extends ConfigFormBase {
public function getFormId() {
return 'fz152_forms_settings';
}
protected function getEditableConfigNames() {
return [
'fz152.settings',
'fz152.forms',
];
}
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this
->config('fz152.forms');
$form['forms'] = [
'#type' => 'textarea',
'#title' => $this
->t('Forms to apply checkbox'),
'#default_value' => $config
->get('forms'),
'#description' => $this
->t('Each form id on the new line, this names are supports wildcard: *_node_form. Also you can specify weight for checkbox: node_edit_news|99. For webforms you can use no weight: default display position under submit button'),
];
return parent::buildForm($form, $form_state);
}
public function submitForm(array &$form, FormStateInterface $form_state) {
$this
->config('fz152.forms')
->set('forms', $form_state
->getValue('forms'))
->save();
parent::submitForm($form, $form_state);
}
}