public function FullCalendar::buildOptionsForm in FullCalendar 8
Same name in this branch
- 8 src/Plugin/views/style/FullCalendar.php \Drupal\fullcalendar\Plugin\views\style\FullCalendar::buildOptionsForm()
- 8 src/Plugin/fullcalendar/type/FullCalendar.php \Drupal\fullcalendar\Plugin\fullcalendar\type\FullCalendar::buildOptionsForm()
Same name and namespace in other branches
- 8.5 src/Plugin/fullcalendar/type/FullCalendar.php \Drupal\fullcalendar\Plugin\fullcalendar\type\FullCalendar::buildOptionsForm()
- 8.2 src/Plugin/fullcalendar/type/FullCalendar.php \Drupal\fullcalendar\Plugin\fullcalendar\type\FullCalendar::buildOptionsForm()
- 8.3 src/Plugin/fullcalendar/type/FullCalendar.php \Drupal\fullcalendar\Plugin\fullcalendar\type\FullCalendar::buildOptionsForm()
- 8.4 src/Plugin/fullcalendar/type/FullCalendar.php \Drupal\fullcalendar\Plugin\fullcalendar\type\FullCalendar::buildOptionsForm()
Overrides FullcalendarInterface::buildOptionsForm
File
- src/
Plugin/ fullcalendar/ type/ FullCalendar.php, line 273
Class
- FullCalendar
- @todo.
Namespace
Drupal\fullcalendar\Plugin\fullcalendar\typeCode
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
/** @var \Drupal\fullcalendar\Plugin\views\style\FullCalendar $style_plugin */
$style_plugin = $this->style;
$form['display'] = [
'#type' => 'details',
'#title' => $this
->t('Display settings'),
'#collapsible' => TRUE,
'#open' => TRUE,
'#prefix' => '<div class="clearfix">',
'#suffix' => '</div>',
];
$form['header'] = [
'#type' => 'details',
'#title' => $this
->t('Header settings'),
'#description' => Link::fromTextAndUrl($this
->t('More info'), Url::fromUri('http://arshaw.com/fullcalendar/docs/display/header', [
'attributes' => [
'target' => '_blank',
],
])),
'#collapsible' => TRUE,
'#open' => FALSE,
'#prefix' => '<div class="clearfix">',
'#suffix' => '</div>',
];
$form['times'] = [
'#type' => 'details',
'#title' => $this
->t('Time/date settings'),
'#description' => Link::fromTextAndUrl($this
->t('More info'), Url::fromUri('http://arshaw.com/fullcalendar/docs/utilities/formatDate', [
'attributes' => [
'target' => '_blank',
],
])),
'#collapsible' => TRUE,
'#open' => FALSE,
'#prefix' => '<div class="clearfix">',
'#suffix' => '</div>',
];
$form['style'] = [
'#type' => 'details',
'#title' => $this
->t('Style settings'),
'#collapsible' => TRUE,
'#open' => FALSE,
];
$form['display']['defaultView'] = [
'#type' => 'select',
'#title' => $this
->t('Initial display'),
'#options' => [
'month' => $this
->t('Month'),
'agendaWeek' => $this
->t('Week (Agenda)'),
'basicWeek' => $this
->t('Week (Basic)'),
'agendaDay' => $this
->t('Day (Agenda)'),
'basicDay' => $this
->t('Day (Basic)'),
],
'#description' => Link::fromTextAndUrl($this
->t('More info'), Url::fromUri('http://arshaw.com/fullcalendar/docs/views/Available_Views', [
'attributes' => [
'target' => '_blank',
],
])),
'#default_value' => $style_plugin->options['display']['defaultView'],
'#prefix' => '<div class="views-left-30">',
'#suffix' => '</div>',
'#fieldset' => 'display',
];
$form['display']['firstDay'] = [
'#type' => 'select',
'#title' => $this
->t('Week starts on'),
'#options' => DateHelper::weekDays(TRUE),
'#default_value' => $style_plugin->options['display']['firstDay'],
'#prefix' => '<div class="views-left-30">',
'#suffix' => '</div>',
'#fieldset' => 'display',
];
$form['display']['weekMode'] = [
'#type' => 'select',
'#title' => $this
->t('Week mode'),
'#options' => [
'fixed' => $this
->t('Fixed'),
'liquid' => $this
->t('Liquid'),
'variable' => $this
->t('Variable'),
],
'#default_value' => $style_plugin->options['display']['weekMode'],
'#description' => Link::fromTextAndUrl($this
->t('More info'), Url::fromUri('http://arshaw.com/fullcalendar/docs/display/weekMode', [
'attributes' => [
'target' => '_blank',
],
])),
'#fieldset' => 'display',
];
$form['left'] = [
'#type' => 'textfield',
'#title' => $this
->t('Left'),
'#default_value' => $style_plugin->options['left'],
'#prefix' => '<div class="views-left-30">',
'#suffix' => '</div>',
'#size' => '30',
'#fieldset' => 'header',
];
$form['center'] = [
'#type' => 'textfield',
'#title' => $this
->t('Center'),
'#default_value' => $style_plugin->options['center'],
'#prefix' => '<div class="views-left-30">',
'#suffix' => '</div>',
'#size' => '30',
'#fieldset' => 'header',
];
$form['right'] = [
'#type' => 'textfield',
'#title' => $this
->t('Right'),
'#default_value' => $style_plugin->options['right'],
'#size' => '30',
'#fieldset' => 'header',
];
$form['times']['default_date'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Use a custom initial date'),
'#description' => $this
->t('If unchecked, the calendar will load the current date.'),
'#default_value' => $style_plugin->options['times']['default_date'],
'#data_type' => 'bool',
'#fieldset' => 'times',
];
$form['times']['date'] = [
'#type' => 'date',
'#title' => $this
->t('Custom initial date'),
'#title_display' => 'invisible',
'#default_value' => $style_plugin->options['times']['date'],
'#states' => [
'visible' => [
':input[name="style_options[times][default_date]"]' => [
'checked' => TRUE,
],
],
],
'#fieldset' => 'times',
];
$form['timeformat'] = [
'#type' => 'textfield',
'#title' => $this
->t('Time format'),
'#default_value' => $style_plugin->options['timeformat'],
'#size' => '30',
'#fieldset' => 'times',
'#states' => [
'visible' => [
':input[name="style_options[advanced]"]' => [
'checked' => FALSE,
],
],
],
];
$form['advanced'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Enable advanced time and date format settings'),
'#default_value' => $style_plugin->options['advanced'],
'#data_type' => 'bool',
'#fieldset' => 'times',
];
$form['slotLabelFormat'] = [
'#type' => 'textfield',
'#title' => $this
->t('Slot label format'),
'#description' => Link::fromTextAndUrl($this
->t('More info'), Url::fromUri('http://arshaw.com/fullcalendar/docs/agenda/slotLabelFormat', [
'attributes' => [
'target' => '_blank',
],
])),
'#default_value' => $style_plugin->options['slotLabelFormat'],
'#size' => '30',
'#fieldset' => 'times',
'#states' => [
'visible' => [
':input[name="style_options[advanced]"]' => [
'checked' => TRUE,
],
],
],
];
// Add the nine time/date formats.
foreach ([
'time',
'title',
'column',
] as $type) {
foreach ([
'Month',
'Week',
'Day',
] as $range) {
$key = $type . 'format' . $range;
$form[$key] = [
'#type' => 'textfield',
'#title' => $this
->t($range),
'#default_value' => $style_plugin->options[$key],
'#size' => '30',
'#fieldset' => $type,
];
if ($range != 'Day') {
$form[$key]['#prefix'] = '<div class="views-left-30">';
$form[$key]['#suffix'] = '</div>';
}
}
}
$form['time'] = [
'#type' => 'details',
'#title' => $this
->t('Time format'),
'#description' => Link::fromTextAndUrl($this
->t('More info'), Url::fromUri('http://arshaw.com/fullcalendar/docs/text/timeFormat', [
'attributes' => [
'target' => '_blank',
],
])),
'#collapsible' => TRUE,
'#open' => TRUE,
'#fieldset' => 'times',
'#prefix' => '<div class="clearfix">',
'#suffix' => '</div>',
'#states' => [
'visible' => [
':input[name="style_options[advanced]"]' => [
'checked' => TRUE,
],
],
],
];
$form['title'] = [
'#type' => 'details',
'#title' => $this
->t('Title format'),
'#description' => Link::fromTextAndUrl($this
->t('More info'), Url::fromUri('http://arshaw.com/fullcalendar/docs/text/titleFormat', [
'attributes' => [
'target' => '_blank',
],
])),
'#collapsible' => TRUE,
'#open' => TRUE,
'#fieldset' => 'times',
'#prefix' => '<div class="clearfix">',
'#suffix' => '</div>',
'#states' => [
'visible' => [
':input[name="style_options[advanced]"]' => [
'checked' => TRUE,
],
],
],
];
$form['column'] = [
'#type' => 'details',
'#title' => $this
->t('Column format'),
'#description' => Link::fromTextAndUrl($this
->t('More info'), Url::fromUri('http://arshaw.com/fullcalendar/docs/text/columnFormat', [
'attributes' => [
'target' => '_blank',
],
])),
'#collapsible' => TRUE,
'#open' => TRUE,
'#fieldset' => 'times',
'#prefix' => '<div class="clearfix">',
'#suffix' => '</div>',
'#states' => [
'visible' => [
':input[name="style_options[advanced]"]' => [
'checked' => TRUE,
],
],
],
];
$form['theme'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Use jQuery UI Theme'),
'#default_value' => $style_plugin->options['theme'],
'#data_type' => 'bool',
'#fieldset' => 'style',
];
$form['sameWindow'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Open events in same window'),
'#default_value' => $style_plugin->options['sameWindow'],
'#data_type' => 'bool',
'#fieldset' => 'style',
'#states' => [
'visible' => [
':input[name="style_options[modalWindow]"]' => [
'checked' => FALSE,
],
],
],
];
$form['modalWindow'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Open events in modal'),
'#default_value' => $style_plugin->options['modalWindow'],
'#data_type' => 'bool',
'#fieldset' => 'style',
'#states' => [
'visible' => [
':input[name="style_options[sameWindow]"]' => [
'checked' => FALSE,
],
],
],
];
$form['contentHeight'] = [
'#type' => 'textfield',
'#title' => $this
->t('Calendar height'),
'#size' => 4,
'#default_value' => $style_plugin->options['contentHeight'],
'#field_suffix' => 'px',
'#data_type' => 'int',
'#fieldset' => 'style',
];
if ($this->moduleHandler
->getImplementations('fullcalendar_droppable')) {
$form['droppable'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Allow external events to be added via drag and drop'),
'#default_value' => $style_plugin->options['droppable'],
'#data_type' => 'bool',
'#fieldset' => 'style',
];
}
$form['editable'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Prevent editing events via drag-and-drop'),
'#default_value' => $style_plugin->options['editable'],
'#data_type' => 'bool',
'#fieldset' => 'style',
'#description' => $this
->t('Modules can set custom access rules, but this will override those.'),
];
// Get the regular fields.
$field_options = $style_plugin->displayHandler
->getFieldLabels();
// Get the date fields.
$date_fields = $style_plugin
->parseFields();
$form['fields'] = [
'#type' => 'details',
'#title' => $this
->t('Customize fields'),
'#description' => $this
->t('Add fields to the view in order to customize fields below.'),
'#collapsible' => TRUE,
'#open' => FALSE,
];
$form['fields']['title'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Use a custom title'),
'#default_value' => $style_plugin->options['fields']['title'],
'#data_type' => 'bool',
'#fieldset' => 'fields',
];
$form['fields']['title_field'] = [
'#type' => 'select',
'#title' => $this
->t('Title field'),
'#options' => $field_options,
'#default_value' => $style_plugin->options['fields']['title_field'],
'#description' => $this
->t('Choose the field with the custom title.'),
'#process' => [
'\\Drupal\\Core\\Render\\Element\\Select::processSelect',
],
'#states' => [
'visible' => [
':input[name="style_options[fields][title]"]' => [
'checked' => TRUE,
],
],
],
'#fieldset' => 'fields',
];
$form['fields']['url'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Use a custom redirect URL'),
'#default_value' => $style_plugin->options['fields']['url'],
'#data_type' => 'bool',
'#fieldset' => 'fields',
];
$form['fields']['url_field'] = [
'#type' => 'select',
'#title' => $this
->t('URL field'),
'#options' => $field_options,
'#default_value' => $style_plugin->options['fields']['url_field'],
'#description' => $this
->t('Choose the field with the custom link.'),
'#process' => [
'\\Drupal\\Core\\Render\\Element\\Select::processSelect',
],
'#states' => [
'visible' => [
':input[name="style_options[fields][url]"]' => [
'checked' => TRUE,
],
],
],
'#fieldset' => 'fields',
];
$form['fields']['date'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Use a custom date field'),
'#default_value' => $style_plugin->options['fields']['date'],
'#data_type' => 'bool',
'#fieldset' => 'fields',
];
$form['fields']['date_field'] = [
'#type' => 'select',
'#title' => $this
->t('Date fields'),
'#options' => $date_fields,
'#default_value' => $style_plugin->options['fields']['date_field'],
'#description' => $this
->t('Select one or more date fields.'),
'#multiple' => TRUE,
'#size' => count($date_fields),
'#process' => [
'\\Drupal\\Core\\Render\\Element\\Select::processSelect',
],
'#states' => [
'visible' => [
':input[name="style_options[fields][date]"]' => [
'checked' => TRUE,
],
],
],
'#fieldset' => 'fields',
];
// Disable form elements when not needed.
if (empty($field_options)) {
$form['fields']['#description'] = $this
->t('All the options are hidden, you need to add fields first.');
$form['fields']['title']['#type'] = 'hidden';
$form['fields']['url']['#type'] = 'hidden';
$form['fields']['date']['#type'] = 'hidden';
$form['fields']['title_field']['#disabled'] = TRUE;
$form['fields']['url_field']['#disabled'] = TRUE;
$form['fields']['date_field']['#disabled'] = TRUE;
}
elseif (empty($date_fields)) {
$form['fields']['date']['#type'] = 'hidden';
$form['fields']['date_field']['#disabled'] = TRUE;
}
}