1 date.admin.inc _date_field_instance_settings_form($field, $instance)

Helper function for date_field_instance_settings_form().

See also

date_field_instance_settings_form_validate()

File

core/modules/date/date.admin.inc, line 194
Admin page callbacks for the Date module.

Code

function _date_field_instance_settings_form($field, $instance) {
  $settings = $instance['settings'];

  $form['default_value'] = array(
    '#type' => 'select',
    '#title' => t('Default date'),
    '#default_value' => $settings['default_value'],
    '#options' => array(
      'blank' => t('No default value'),
      'now' => t('Now'),
      'strtotime' => t('Relative'),
    ),
    '#weight' => 1,
    '#fieldset' => 'default_values',
  );

  $description = t("Describe a time by reference to the current day, like '+90 days' (90 days from the day the field is created) or '+1 Saturday' (the next Saturday). See !strtotime for more details.", array('!strtotime' => l(t('strtotime'), 'http://www.php.net/manual/en/function.strtotime.php')));
  $form['default_value_code'] = array(
    '#type' => 'textfield',
    '#title' => t('Relative default value'),
    '#description' => $description,
    '#default_value' => $settings['default_value_code'],
    '#states' => array(
      'visible' => array(
        ':input[name="instance[settings][default_value]"]' => array(
          'value' => 'strtotime',
        ),
      ),
    ),
    '#weight' => 1.1,
    '#fieldset' => 'default_values',
  );
  $form['default_value2'] = array(
    '#type' => !empty($field['settings']['todate']) ? 'select' : 'hidden',
    '#title' => t('Default end date'),
    '#default_value' => $settings['default_value2'],
    '#options' => array(
      'same' => t('Same as Default date'),
      'blank' => t('No default value'),
      'now' => t('Now'),
      'strtotime' => t('Relative'),
    ),
    '#weight' => 2,
    '#fieldset' => 'default_values',
  );
  $form['default_value_code2'] = array(
    '#type' => !empty($field['settings']['todate']) ? 'textfield' : 'hidden',
    '#title' => t('Relative default value for end date'),
    '#description' => $description,
    '#default_value' => $settings['default_value_code2'],
    '#states' => array(
      'visible' => array(
        ':input[name="instance[settings][default_value2]"]' => array(
          'value' => 'strtotime',
        ),
      ),
    ),
    '#weight' => 2.1,
    '#fieldset' => 'default_values',
  );

  $form['#element_validate'] = array('date_field_instance_settings_form_validate');

  $context = array(
    'field' => $field,
    'instance' => $instance,
  );
  backdrop_alter('date_field_instance_settings_form', $form, $context);

  return $form;
}