public function FullcalendarForm::buildForm in Booking and Availability Management Tools for Drupal 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
- modules/
bat_fullcalendar/ src/ Form/ FullcalendarForm.php, line 30
Class
Namespace
Drupal\bat_fullcalendar\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this
->config('bat_fullcalendar.settings');
$form['bat_fullcalendar_scheduler'] = [
'#type' => 'container',
'#prefix' => '<div id="label-settings">',
'#suffix' => '</div>',
];
$form['bat_fullcalendar_scheduler']['bat_fullcalendar_scheduler_key'] = [
'#type' => 'radios',
'#title' => t('FullCalendar Scheduler License'),
'#default_value' => $config
->get('bat_fullcalendar_scheduler_key'),
'#options' => [
'commercial' => t('Commercial License'),
'non-commercial' => t('Non-Commercial Creative Commons'),
'gpl' => t('GPL License'),
'none' => t('None'),
],
'#description' => t('Please visit http://fullcalendar.io/scheduler/license/ to find out about the license terms for the Scheduler View of FullCalendar'),
'#ajax' => [
'callback' => [
$this,
'fullcalendarSettingsAjax',
],
'wrapper' => 'label-settings',
],
];
$values = $form_state
->getValues();
if (isset($values['bat_fullcalendar_scheduler_key']) && $values['bat_fullcalendar_scheduler_key'] == 'commercial' || !isset($values['bat_fullcalendar_scheduler_key']) && $config
->get('bat_fullcalendar_scheduler_key') == 'commercial') {
$form['bat_fullcalendar_scheduler']['bat_fullcalendar_scheduler_commercial_key'] = [
'#type' => 'textfield',
'#title' => t('FullCalendar Scheduler Commercial License Key'),
'#required' => TRUE,
'#default_value' => $config
->get('bat_fullcalendar_scheduler_commercial_key'),
];
}
return parent::buildForm($form, $form_state);
}