You are here

function field_validation_date_range2_validator::settings_form in Field Validation 7.2

Provide settings option

Overrides field_validation_validator::settings_form

File

plugins/validator/field_validation_date_range2_validator.inc, line 106

Class

field_validation_date_range2_validator

Code

function settings_form(&$form, &$form_state) {
  $default_settings = $this
    ->get_default_settings($form, $form_state);

  //print debug($default_settings);
  $form['settings']['cycle'] = array(
    '#title' => t('Cycle of date'),
    '#description' => t("Specify the cycle of date, support: global, year, month, week, day, hour, minute."),
    '#type' => 'select',
    '#options' => array(
      'global' => t('Global'),
      'year' => t('Year'),
      'month' => t('Month'),
      'week' => t('Week'),
      'day' => t('Day'),
      'hour' => t('Hour'),
      'minute' => t('Minute'),
    ),
    '#default_value' => isset($default_settings['cycle']) ? $default_settings['cycle'] : '',
  );
  $form['settings']['min'] = array(
    '#title' => t('Minimum date'),
    '#description' => t("Optionally specify the minimum date."),
    '#type' => 'textfield',
    '#default_value' => isset($default_settings['min']) ? $default_settings['min'] : '',
  );
  $form['settings']['max'] = array(
    '#title' => t('Maximum date'),
    '#description' => t("Optionally specify the maximum date."),
    '#type' => 'textfield',
    '#default_value' => isset($default_settings['max']) ? $default_settings['max'] : '',
  );
  $form['settings']['help'] = array(
    '#markup' => t('For minimum and maximum time, we only support date format "Y-m-d H:i:s", here is the relation between cycle and minimum/maximum date format:') . theme('item_list', array(
      'items' => array(
        t('global - [Y-m-d H:i:s]'),
        t('year - [m-d H:i:s]'),
        t('month - [d H:i:s]'),
        t('week - [w H:i:s]'),
        t('day - [H:i:s]'),
        t('hour - [i:s]'),
        t('minute - [s]'),
      ),
    )) . t('If cycle is "global", it support more date formats which could be converted through strtotime(), such as "now", "+1 month", "+1 day", it also support "value + 1 day", "value2 - 1 day", at here "value" means start date of user input, "value2" means end date'),
  );
  $form['settings']['reverse'] = array(
    '#title' => t('Reverse'),
    '#description' => t("If it is checked, it means must not match the range."),
    '#type' => 'checkbox',
    '#default_value' => isset($default_settings['reverse']) ? $default_settings['reverse'] : FALSE,
  );
  parent::settings_form($form, $form_state);
}