You are here

function field_collection_item_form in Field collection 7

Form for editing a field collection item.

@todo implement hook_forms().

2 string references to 'field_collection_item_form'
field_collection_item_add in ./field_collection.pages.inc
Add a new field collection item.
field_collection_menu in ./field_collection.module
Implements hook_menu().

File

./field_collection.pages.inc, line 24
Provides the field collection item view / edit / delete pages.

Code

function field_collection_item_form($form, &$form_state, $field_collection_item) {
  if (!isset($field_collection_item->is_new)) {
    drupal_set_title($field_collection_item
      ->label());
  }
  $form_state += array(
    'field_collection_item' => $field_collection_item,
  );

  // Hack: entity_form_field_validate() needs the bundle to be set.
  // @todo: Fix core and remove the hack.
  $form['field_name'] = array(
    '#type' => 'value',
    '#value' => $field_collection_item->field_name,
  );
  $langcode = entity_language('field_collection_item', $field_collection_item);
  field_attach_form('field_collection_item', $field_collection_item, $form, $form_state, $langcode);
  $form['actions'] = array(
    '#type' => 'actions',
    '#weight' => 50,
  );
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
    '#weight' => 5,
  );
  return $form;
}