public function ExtraBodyClassesConfigForm::buildForm in Extra body classes 8
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/ ExtraBodyClassesConfigForm.php, line 48
Class
- ExtraBodyClassesConfigForm
- Configure where you want to append "extra body classes".
Namespace
Drupal\extra_body_classes\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this->configFactory
->get('extra_body_classes.settings');
$form['extra_body_classes_time'] = [
'#type' => 'details',
'#title' => $this
->t('Extra Body Classes Based On Time'),
'#open' => TRUE,
];
// Add current browser details.
$form['extra_body_classes_browser_details_status'] = [
'#type' => 'details',
'#title' => $this
->t('Extra Body Classes Based Current Browser Details'),
'#open' => TRUE,
];
$form['extra_body_classes_browser_details_status']['extra_body_classes_browser_platform'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Add current browser platform'),
'#description' => $this
->t('Add name of current browsers platform, Example: mac'),
'#default_value' => $config
->get('extra_body_classes_browser_platform'),
];
$form['extra_body_classes_browser_details_status']['extra_body_classes_browser_name_version'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Add current browser name and version'),
'#description' => $this
->t('Add current browser name and version, Example: chrom chrom46'),
'#default_value' => $config
->get('extra_body_classes_browser_name_version'),
];
$form['extra_body_classes_browser_details_status']['extra_body_classes_browser_device'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Add current device'),
'#description' => $this
->t('Add current device, Example: Desktop'),
'#default_value' => $config
->get('extra_body_classes_browser_device'),
];
// Add current date as class.
$form['extra_body_classes_time']['extra_body_classes_date'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Current Date Timestamp'),
'#description' => $this
->t('Add a current date timestamp as class to body tag'),
'#default_value' => $config
->get('extra_body_classes_date'),
];
// Add current year as class.
$form['extra_body_classes_time']['extra_body_classes_year'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Current Year'),
'#description' => $this
->t('Add a current year as class to body tag'),
'#default_value' => $config
->get('extra_body_classes_year'),
];
// Add current month as class.
$form['extra_body_classes_time']['extra_body_classes_month'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Current Month'),
'#description' => $this
->t('Add a current month as class to body tag'),
'#default_value' => $config
->get('extra_body_classes_month'),
];
// Add current day as class.
$form['extra_body_classes_time']['extra_body_classes_day'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Current Day'),
'#description' => $this
->t('Add a current day as class to body tag'),
'#default_value' => $config
->get('extra_body_classes_day'),
];
// Add current user roles as class.
$form['extra_body_classes_roles_status'] = [
'#type' => 'details',
'#title' => $this
->t('Extra Body Classes Based On Roles'),
'#open' => TRUE,
];
$form['extra_body_classes_roles_status']['extra_body_classes_roles'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Current user roles'),
'#description' => $this
->t('Add a current user roles as class to body tag'),
'#default_value' => $config
->get('extra_body_classes_roles'),
];
// Add Event For Single Day.
$form['extra_body_classes_browser_single_day_event_status'] = [
'#type' => 'details',
'#title' => $this
->t('Extra Body Classes Based single day Event'),
'#open' => TRUE,
];
$form['extra_body_classes_browser_single_day_event_status']['extra_body_classes_browser_single_day_event'] = [
'#type' => 'textfield',
'#title' => $this
->t('Add event class'),
'#description' => $this
->t('Add event Example: independence day'),
'#default_value' => $config
->get('extra_body_classes_browser_single_day_event'),
];
$form['extra_body_classes_browser_single_day_event_status']['extra_body_classes_browser_single_day_event_begins'] = [
'#type' => 'date',
'#title' => $this
->t('Event Day'),
'#description' => $this
->t('Add event date.'),
'#default_value' => $config
->get('extra_body_classes_browser_single_day_event_begins'),
];
// Add Event For Multiple Days.
$form['extra_body_classes_browser_multiple_days_event_status'] = [
'#type' => 'details',
'#title' => $this
->t('Extra Body Classes Based multiple day Event'),
'#open' => TRUE,
];
$form['extra_body_classes_browser_multiple_days_event_status']['extra_body_classes_event'] = [
'#type' => 'textfield',
'#title' => $this
->t('Add current event'),
'#description' => $this
->t('Add current event Example: Drupal con asia 18 feb - 21 feb'),
'#default_value' => $config
->get('extra_body_classes_event'),
];
$form['extra_body_classes_browser_multiple_days_event_status']['extra_body_classes_event_start_date'] = [
'#type' => 'date',
'#title' => $this
->t('Start Date'),
'#description' => $this
->t('Add start date of current event.'),
'#default_value' => $config
->get('extra_body_classes_event_start_date'),
];
$form['extra_body_classes_browser_multiple_days_event_status']['extra_body_classes_event_end_date'] = [
'#type' => 'date',
'#title' => $this
->t('End Date'),
'#description' => $this
->t('Add end date of current event.'),
'#default_value' => $config
->get('extra_body_classes_event_end_date'),
];
// Add custom classes.
$form['extra_body_classes_custom_classes_status'] = [
'#type' => 'details',
'#title' => $this
->t('Extra Body Classes Based On Custom Classes'),
'#open' => TRUE,
];
$form['extra_body_classes_custom_classes_status']['extra_body_classes_custom_classes'] = [
'#type' => 'textfield',
'#title' => $this
->t('Add custom classes'),
'#description' => $this
->t('Add multiple custom classes in small letters separated by comma, Example: abc,xyz'),
'#default_value' => $config
->get('extra_body_classes_custom_classes'),
];
$form['extra_body_classes_custom_classes_status']['extra_body_classes_custom_classes_path'] = [
'#type' => 'textarea',
'#title' => $this
->t('Add page url'),
'#description' => $this
->t("Specify pages by using their paths. Enter one path per line. Example: node/1 or about-us"),
'#default_value' => $config
->get('extra_body_classes_custom_classes_path'),
];
return parent::buildForm($form, $form_state);
}