public function SiteWideJSForm::buildForm in Open Social 8
Same name and namespace in other branches
- 8.9 modules/custom/sitewide_js/src/Form/SiteWideJSForm.php \Drupal\sitewide_js\Form\SiteWideJSForm::buildForm()
- 8.2 modules/custom/sitewide_js/src/Form/SiteWideJSForm.php \Drupal\sitewide_js\Form\SiteWideJSForm::buildForm()
- 8.3 modules/custom/sitewide_js/src/Form/SiteWideJSForm.php \Drupal\sitewide_js\Form\SiteWideJSForm::buildForm()
- 8.4 modules/custom/sitewide_js/src/Form/SiteWideJSForm.php \Drupal\sitewide_js\Form\SiteWideJSForm::buildForm()
- 8.5 modules/custom/sitewide_js/src/Form/SiteWideJSForm.php \Drupal\sitewide_js\Form\SiteWideJSForm::buildForm()
- 8.6 modules/custom/sitewide_js/src/Form/SiteWideJSForm.php \Drupal\sitewide_js\Form\SiteWideJSForm::buildForm()
- 8.7 modules/custom/sitewide_js/src/Form/SiteWideJSForm.php \Drupal\sitewide_js\Form\SiteWideJSForm::buildForm()
- 8.8 modules/custom/sitewide_js/src/Form/SiteWideJSForm.php \Drupal\sitewide_js\Form\SiteWideJSForm::buildForm()
- 10.3.x modules/custom/sitewide_js/src/Form/SiteWideJSForm.php \Drupal\sitewide_js\Form\SiteWideJSForm::buildForm()
- 10.0.x modules/custom/sitewide_js/src/Form/SiteWideJSForm.php \Drupal\sitewide_js\Form\SiteWideJSForm::buildForm()
- 10.1.x modules/custom/sitewide_js/src/Form/SiteWideJSForm.php \Drupal\sitewide_js\Form\SiteWideJSForm::buildForm()
- 10.2.x modules/custom/sitewide_js/src/Form/SiteWideJSForm.php \Drupal\sitewide_js\Form\SiteWideJSForm::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 ConfigFormBase::buildForm
File
- modules/
custom/ sitewide_js/ src/ Form/ SiteWideJSForm.php, line 34
Class
- SiteWideJSForm
- Class SiteWideJSForm.
Namespace
Drupal\sitewide_js\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this
->config('sitewide_js.settings');
$form['warning']['#markup'] = $this
->t('<h2>Warning</h2><p>Be careful, in this section you can make sitewide changes to the HTML template and therefore break both the front-end javascript applications and the layout for your website.</p>');
$form['swjs_enabled'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Enable site wide JS'),
'#description' => $this
->t('Turn sitewide JS on or off.'),
'#default_value' => $config
->get('swjs_enabled'),
];
$form['swjs_location'] = [
'#type' => 'radios',
'#title' => $this
->t('JS Location'),
'#description' => $this
->t('The output location of the sitewide JS.'),
'#default_value' => $config
->get('swjs_location'),
'#options' => [
0 => $this
->t('Header'),
1 => $this
->t('Footer'),
],
];
$form['swjs_footer_region'] = [
'#type' => 'textfield',
'#title' => $this
->t('Footer region'),
'#description' => $this
->t('Footer region to put the JS in.'),
'#default_value' => $config
->get('swjs_footer_region'),
'#states' => [
'visible' => [
':input[name="swjs_location"]' => [
'value' => '1',
],
],
],
];
$form['swjs_javascript'] = [
'#type' => 'textarea',
'#title' => $this
->t('Javascript'),
'#description' => $this
->t('The JS to add to the site.'),
'#default_value' => $config
->get('swjs_javascript'),
];
return parent::buildForm($form, $form_state);
}