function system_configure_date_formats_form
system_configure_date_formats_form($form, &$form_state, $dfid = 0)
Allow users to add additional date formats.
File
- modules/system/system.admin.inc, line 2882
- Admin page callbacks for the system module.
Code
function system_configure_date_formats_form($form, &$form_state, $dfid = 0) { $ajax_path = 'admin/config/regional/date-time/formats/lookup'; $js_settings = array( 'type' => 'setting', 'data' => array( 'dateTime' => array( 'date-format' => array( 'text' => t('Displayed as'), 'lookup' => url($ajax_path, array('query' => array('token' => drupal_get_token($ajax_path)))), ), ), ), ); 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; }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!system!system.admin.inc/function/system_configure_date_formats_form/7.x