You are here

function fape_field_edit_node_created_form in Field API Pane Editor (FAPE) 7

Subform to edit the entity 'created' field.

This isn't a true form. As such it modifies the $form by reference.

1 string reference to 'fape_field_edit_node_created_form'
fape_field_edit_page in ./fape.module
Page callback to edit an entity field.

File

./fape.module, line 383
Adds direct field editing via contextual links.

Code

function fape_field_edit_node_created_form(&$form, &$form_state) {
  $node = $form_state['entity'];

  // It is necessary to call node_object_prepare() on the node to calculate
  // the node's creation date.
  node_object_prepare($node);
  $time = !empty($node->date) ? date_format(date_create($node->date), 'Y-m-d H:i:s O') : format_date($node->created, 'custom', 'Y-m-d H:i:s O');
  $timezone = !empty($node->date) ? date_format(date_create($node->date), 'O') : format_date($node->created, 'custom', 'O');
  $form['date'] = array(
    '#type' => 'textfield',
    '#title' => t('Authored on'),
    '#maxlength' => 25,
    '#description' => t('Format: %time. The date format is YYYY-MM-DD and %timezone is the time zone offset from UTC. Leave blank to use the time of form submission.', array(
      '%time' => $time,
      '%timezone' => $timezone,
    )),
    '#default_value' => !empty($node->date) ? $node->date : '',
  );
  $form['#validate'][] = 'fape_field_edit_node_created_form_validate';
  $form['#submit'][] = 'fape_field_edit_node_created_form_submit';
}