You are here

function datex_date_field_widget_settings_form_alter in Datex 7.3

Same name and namespace in other branches
  1. 7.2 datex_date.inc \datex_date_field_widget_settings_form_alter()

Implements hook_date_field_instance_settings_form_alter().

For per-field control.

File

./datex_date.inc, line 353
Provides support for date module.

Code

function datex_date_field_widget_settings_form_alter(&$form, $context) {
  $granularity = $context['field']['settings']['granularity'];
  $schema = _datex_element_schema($context);
  if (_datex_granularity_supported($granularity)) {
    $form['datex_schema'] = [
      '#title' => t('Datex Schema'),
      '#type' => 'select',
      '#options' => _datex_schema_form_options(),
      '#default_value' => $schema,
    ];
  }
  else {
    $form['datex_schema'] = [
      '#title' => t('Datex Schema'),
      '#type' => 'select',
      '#options' => [
        'disabled' => t('Disabled'),
      ],
      '#default_value' => 'disabled',
      '#disabled' => TRUE,
      '#description' => t('Datex will be disabled for fields without ' . 'month granularity but with smaller granularity.'),
    ];
  }
}