You are here

function _webform_edit_date in Webform 7.4

Same name and namespace in other branches
  1. 5.2 components/date.inc \_webform_edit_date()
  2. 5 components/date.inc \_webform_edit_date()
  3. 6.3 components/date.inc \_webform_edit_date()
  4. 6.2 components/date.inc \_webform_edit_date()
  5. 7.3 components/date.inc \_webform_edit_date()

Implements _webform_edit_component().

File

components/date.inc, line 58
Webform module date component.

Code

function _webform_edit_date($component) {
  $form = array();
  $form['value'] = array(
    '#type' => 'textfield',
    '#title' => t('Default value'),
    '#default_value' => $component['value'],
    '#description' => t('The default value of the field.') . '<br />' . t('Accepts any date in any <a href="http://www.gnu.org/software/tar/manual/html_chapter/Date-input-formats.html">GNU Date Input Format</a>. Strings such as today, +2 months, and Dec 9 2004 are all valid.'),
    '#size' => 60,
    '#maxlength' => 127,
    '#weight' => 0,
  );
  $form['extra']['timezone'] = array(
    '#type' => 'radios',
    '#title' => t('Default value timezone'),
    '#default_value' => empty($component['extra']['timezone']) ? 'user' : $component['extra']['timezone'],
    '#description' => t('If using relative dates for a default value (for example, "today") base the current day on this timezone.'),
    '#options' => array(
      'user' => t('User timezone'),
      'site' => t('Website timezone'),
    ),
    '#weight' => 2,
    '#access' => variable_get('configurable_timezones', 1),
  );
  $form['extra']['exclude'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Hide'),
    '#default_value' => $component['extra']['exclude'],
    '#options' => array(
      'day' => t('Day'),
      'month' => t('Month'),
      'year' => t('Year'),
    ),
    '#description' => t('A hidden day or month will be set to 1. A hidden year will be set to the year of the default value.'),
    '#weight' => 3,
  );
  $form['display']['datepicker'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable popup calendar'),
    '#default_value' => $component['extra']['datepicker'],
    '#description' => t('Enable a JavaScript date picker next to the date field.'),
    '#weight' => 2,
    '#parents' => array(
      'extra',
      'datepicker',
    ),
  );
  $form['display']['year_textfield'] = array(
    '#type' => 'checkbox',
    '#title' => t('Use a textfield for year'),
    '#default_value' => $component['extra']['year_textfield'],
    '#description' => t('If checked, the generated date field will use a textfield for the year. Otherwise it will use a select list.'),
    '#weight' => 5,
    '#parents' => array(
      'extra',
      'year_textfield',
    ),
  );
  $form['validation']['start_date'] = array(
    '#type' => 'textfield',
    '#title' => t('Start date'),
    '#default_value' => $component['extra']['start_date'],
    '#description' => t('The earliest date that may be entered into the field.') . ' ' . t('Accepts any date in any <a href="http://www.gnu.org/software/tar/manual/html_chapter/Date-input-formats.html">GNU Date Input Format</a>.'),
    '#size' => 30,
    '#weight' => 3,
    '#parents' => array(
      'extra',
      'start_date',
    ),
  );
  $form['validation']['end_date'] = array(
    '#type' => 'textfield',
    '#title' => t('End date'),
    '#default_value' => $component['extra']['end_date'],
    '#description' => t('The latest date that may be entered into the field.') . ' ' . t('Accepts any date in any <a href="http://www.gnu.org/software/tar/manual/html_chapter/Date-input-formats.html">GNU Date Input Format</a>.'),
    '#size' => 30,
    '#weight' => 4,
    '#parents' => array(
      'extra',
      'end_date',
    ),
  );
  $form['#validate'] = array(
    '_webform_edit_date_validate',
  );
  return $form;
}