public function PopupSettingsForm::buildForm in Popup Dialog 8
Same name and namespace in other branches
- 8.2 src/Form/PopupSettingsForm.php \Drupal\popup_dialog\Form\PopupSettingsForm::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
- src/
Form/ PopupSettingsForm.php, line 34
Class
- PopupSettingsForm
- Class PopupSettingsForm.
Namespace
Drupal\popup_dialog\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this
->config('popup_dialog.settings');
$form['popup_enabled'] = array(
'#type' => 'checkbox',
'#title' => $this
->t('Enabled'),
'#description' => $this
->t('Popup will be enabled when the checkbox is active.'),
'#default_value' => $config
->get('popup_enabled'),
);
$form['popup_settings'] = array(
'#type' => 'details',
'#title' => $this
->t('Popup Box Settings'),
'#open' => TRUE,
);
$form['popup_settings']['popup_box_title'] = array(
'#type' => 'textfield',
'#title' => $this
->t('Title'),
'#description' => $this
->t('The title for the popup dialog box.'),
'#maxlength' => 64,
'#size' => 64,
'#default_value' => $config
->get('popup_box_title'),
);
$form['popup_settings']['popup_box_body'] = [
'#type' => 'text_format',
'#title' => $this
->t('Body'),
'#default_value' => $config
->get('popup_box_body')['value'],
'#format' => $config
->get('popup_box_body')['format'],
];
$form['popup_settings']['delay'] = array(
'#type' => 'number',
'#title' => $this
->t('Delay'),
'#description' => $this
->t('Show message after the enter number of seconds. Enter 0 to show instantly.'),
'#default_value' => $config
->get('delay'),
);
$form['popup_settings']['popup_top_position'] = array(
'#type' => 'number',
'#title' => $this
->t('Top Offset'),
'#description' => $this
->t('Set the offset in px how much the popup box should be away from the top edge of the screen.'),
'#default_value' => $config
->get('popup_top_position'),
);
return parent::buildForm($form, $form_state);
}