You are here

public static function RulesDataUIDate::inputForm in Rules 7.2

Implements RulesDataDirectInputFormInterface::inputForm().

Overrides RulesDataUIText::inputForm

File

ui/ui.data.inc, line 402
Contains data type related forms.

Class

RulesDataUIDate
UI for dates.

Code

public static function inputForm($name, $info, $settings, RulesPlugin $element) {
  $settings += array(
    $name => isset($info['default value']) ? $info['default value'] : (empty($info['optional']) ? gmdate('Y-m-d H:i:s', time()) : NULL),
  );

  // Convert any configured timestamp into a readable format.
  if (is_numeric($settings[$name])) {
    $settings[$name] = gmdate('Y-m-d H:i:s', $settings[$name]);
  }
  $form = parent::inputForm($name, $info, $settings, $element);
  $form[$name]['#type'] = 'textfield';
  $form[$name]['#element_validate'][] = 'rules_ui_element_date_validate';

  // Note that the date input evaluator takes care for parsing dates using
  // strtotime() into a timestamp, which is the internal date format.
  $form[$name]['#description'] = t('The date in GMT. You may enter a fixed time (like %format) or any other values in GMT known by the PHP !strtotime function (like "+1 day"). Relative dates like "+1 day" or "now" relate to the evaluation time.', array(
    '%format' => gmdate('Y-m-d H:i:s', time() + 86400),
    '!strtotime' => l('strtotime()', 'http://php.net/strtotime'),
  ));

  // @todo Leverage the jquery datepicker+timepicker once a module providing
  // The timepicker is available.
  return $form;
}