function system_configure_date_formats_form
7.x system.admin.inc | system_configure_date_formats_form($form, &$form_state, $dfid = 0) |
Allow users to add additional date formats.
1 string reference to 'system_configure_date_formats_form'
- system_menu in drupal-7.x/
modules/ system/ system.module - Implements hook_menu().
File
- drupal-7.x/
modules/ system/ system.admin.inc, line 2863 - Admin page callbacks for the system module.
Code
function system_configure_date_formats_form($form, &$form_state, $dfid = 0) {
$js_settings = array(
'type' => 'setting',
'data' => array(
'dateTime' => array(
'date-format' => array(
'text' => t('Displayed as'),
'lookup' => url('admin/config/regional/date-time/formats/lookup'),
),
),
),
);
if ($dfid) {
$form['dfid'] = array(
'#type' => 'value',
'#value' => $dfid,
);
$format = system_get_date_format($dfid);
}
$now = ($dfid ? t('Displayed as %date', array('%date' => format_date(REQUEST_TIME, 'custom', $format->format))) : '');
$form['date_format'] = array(
'#type' => 'textfield',
'#title' => t('Format string'),
'#maxlength' => 100,
'#description' => t('A user-defined date format. See the <a href="@url">PHP manual</a> for available options.', array('@url' => 'http://php.net/manual/function.date.php')),
'#default_value' => ($dfid ? $format->format : ''),
'#field_suffix' => ' <small id="edit-date-format-suffix">' . $now . '</small>',
'#attached' => array(
'js' => array(drupal_get_path('module', 'system') . '/system.js', $js_settings),
),
'#required' => TRUE,
);
$form['actions'] = array('#type' => 'actions');
$form['actions']['update'] = array(
'#type' => 'submit',
'#value' => ($dfid ? t('Save format') : t('Add format')),
);
$form['#validate'][] = 'system_add_date_formats_form_validate';
$form['#submit'][] = 'system_add_date_formats_form_submit';
return $form;
}