You are here

function quickedit_field_edit_form in Quick Edit 7

Form constructor; in-place editing form for a (single) Field API field.

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

This leverages http://drupal.org/node/1825844.

See also

quickedit_field_edit_form_validate()

quickedit_field_edit_form_submit()

1 string reference to 'quickedit_field_edit_form'
quickedit_field_edit in includes/pages.inc
Page callback: Returns a single field edit form as an Ajax response.

File

includes/fape.inc, line 20
This is now effectively a light-weight duplicate of FAPE.module, providing just the parts Quick Edit needs.

Code

function quickedit_field_edit_form(&$form, &$form_state, $entity, $field_name) {
  $entity_type = $form_state['entity_type'];
  $langcode = $form_state['langcode'];
  $bundle = $form_state['bundle'];

  // Adds the form elements for only the specified field to the form.
  $options = array(
    'field_name' => $field_name,
    'language' => field_valid_language($langcode),
    'default' => TRUE,
  );
  field_attach_form($entity_type, $entity, $form, $form_state, $langcode, $options);
  $entity->revision = FALSE;

  // @todo make this not node-specific
  if ($entity_type === 'node') {
    $entity->revision = in_array('revision', variable_get('node_options_' . $bundle, array()));
    $entity->log = NULL;
  }
  $form['#validate'][] = 'quickedit_field_edit_form_validate';
  $form['#submit'][] = 'quickedit_field_edit_form_submit';
}