You are here

function fape_field_edit_form in Field API Pane Editor (FAPE) 7

Field editing form.

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

File

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

Code

function fape_field_edit_form($form, &$form_state) {

  // Since we could edit a number of different things here, immediately
  // add whatever else is needed.
  $form_state['subform_id']($form, $form_state);
  $form['#parents'] = array();
  $entity_type = $form_state['entity_type'];
  $entity = $form_state['entity'];
  $bundle = $form_state['bundle'];
  list($use_revisions, $control_revisions) = _fape_entity_allows_revisions($entity_type, $bundle, $entity);
  if ($use_revisions) {
    $form_state['use revisions'] = TRUE;
    $form['revision_information'] = array(
      '#weight' => 11,
    );
    $form['revision_information']['revision'] = array(
      '#type' => 'checkbox',
      '#title' => t('Create new revision'),
      '#default_value' => $entity->revision,
      '#id' => 'edit-revision',
      '#access' => $control_revisions,
    );
    if ($control_revisions || $entity->revision) {
      $form['revision_information']['log'] = array(
        '#type' => 'textarea',
        '#title' => t('Log message'),
        '#description' => t('Provide an explanation of the changes you are making. This will help other authors understand your motivations.'),
        '#default_value' => $entity->log,
      );
      if ($control_revisions) {
        $form['revision_information']['log']['#dependency'] = array(
          'edit-revision' => array(
            1,
          ),
        );
      }
    }
  }
  $form['actions'] = array(
    '#type' => 'actions',
  );
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
  );
  $form['actions']['cancel'] = array(
    '#type' => 'submit',
    '#value' => t('Cancel'),
    '#validate' => array(
      'fape_field_edit_form_cancel',
    ),
    '#executes_submit_callback' => FALSE,
  );

  // Ensure this actually gets on there.
  $form['#submit'][] = 'fape_field_edit_form_submit';
  return $form;
}