public function SmartdateFieldBuilder::buildConfigurationForm in Smart Date 3.3.x
Same name and namespace in other branches
- 3.4.x src/Plugin/diff/Field/SmartdateFieldBuilder.php \Drupal\smart_date\Plugin\diff\Field\SmartdateFieldBuilder::buildConfigurationForm()
File
- src/
Plugin/ diff/ Field/ SmartdateFieldBuilder.php, line 63
Class
- SmartdateFieldBuilder
- Plugin to diff text fields.
Namespace
Drupal\smart_date\Plugin\diff\FieldCode
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
unset($form['format_type']);
// Change the description of the timezone_override element.
if (isset($form['timezone_override'])) {
$form['timezone_override']['#description'] = $this
->t('The time zone selected here will be used unless overridden on an individual date.');
}
// Ask the user to choose a Smart Date Format.
$formatOptions = [];
$smartDateFormats = \Drupal::entityTypeManager()
->getStorage('smart_date_format')
->loadMultiple();
foreach ($smartDateFormats as $type => $format) {
if ($format instanceof SmartDateFormat) {
$formatted = static::formatSmartDate(time(), time() + 3600, $format
->getOptions(), NULL, 'string');
$formatOptions[$type] = $format
->label() . ' (' . $formatted . ')';
}
}
$form['format'] = [
'#type' => 'select',
'#title' => $this
->t('Smart Date Format'),
'#description' => $this
->t('Choose which display configuration to use.'),
'#default_value' => 'default',
'#options' => $formatOptions,
];
return parent::buildConfigurationForm($form, $form_state);
}