AddToCalendarField.php in Add To Calendar Button (AddEvent.com) 8.3
File
src/Plugin/Field/FieldType/AddToCalendarField.php
View source
<?php
namespace Drupal\addtocalendar\Plugin\Field\FieldType;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\Core\Field\Plugin\Field\FieldType\BooleanItem;
class AddToCalendarField extends BooleanItem {
public static function defaultFieldSettings() {
$addtocalendar_settings = [
'style' => 'glow_orange',
];
$settings = [
'addtocalendar_show' => '1',
'addtocalendar_settings' => $addtocalendar_settings,
'on_label' => new TranslatableMarkup('Add to Calendar'),
'off_label' => new TranslatableMarkup('Add to Calendar Disabled'),
];
return $settings;
}
public function fieldSettingsForm(array $form, FormStateInterface $form_state) {
$element = parent::fieldSettingsForm($form, $form_state);
$settings = $this
->getSettings();
$element['off_label']['#required'] = FALSE;
$field_definition = $this->definition
->getFieldDefinition();
$element += _addtocalendar_build_form($settings, $field_definition);
$element['addtocalendar_show']['#title'] = t('Add to Calendar settings');
$element['on_label']['#title'] = $this
->t('Display Text');
$element['off_label']['#title'] = $this
->t('Disabled Text');
unset($element['addtocalendar_settings']['display_text']);
return $element;
}
}