You are here

function addtocalendar_field_formatter_third_party_settings_form in Add To Calendar Button (AddEvent.com) 8.3

Same name and namespace in other branches
  1. 8 addtocalendar.module \addtocalendar_field_formatter_third_party_settings_form()
  2. 8.2 addtocalendar.module \addtocalendar_field_formatter_third_party_settings_form()

Implements hook_field_formatter_third_party_settings_form().

File

./addtocalendar.module, line 27
Contains module code.

Code

function addtocalendar_field_formatter_third_party_settings_form($plugin, $field_definition, $view_mode, $form, $form_state) {
  $element = [];
  if ($plugin
    ->getPluginId() !== 'add_to_calendar') {

    // Make sure to avoid confliction in case add_to_calendar field formatter is
    // used.
    if (count(array_intersect([
      'datetime',
      'daterange',
    ], $plugin
      ->getPluginDefinition()['field_types']))) {
      $settings = $plugin
        ->getThirdPartySettings('addtocalendar');
      $element = _addtocalendar_build_form($settings, $field_definition);

      // Unset the start date to avoid conflicts.
      if (isset($element['addtocalendar_settings']['atc_date_start'])) {
        unset($element['addtocalendar_settings']['atc_date_start']);
      }
    }
  }
  return $element;
}