You are here

function eva_field_attach_form in EVA: Entity Views Attachment 7

Implements hook_field_attach_form().

File

./eva.module, line 86

Code

function eva_field_attach_form($entity_type, $entity, &$form, &$form_state, $langcode) {

  // Retrieve all EVA views for this entity type.
  if (!($views = eva_get_views($entity_type))) {
    return;
  }

  // If there are no extra fields for this entity, return.
  list(, , $bundle) = entity_extract_ids($entity_type, $entity);
  if (!($fields = field_info_extra_fields($entity_type, $bundle, 'form'))) {
    return;
  }

  // Loop through each view to see if it is an extra field. Unlike fields on the
  // display, fields on the form have no concept of visibility, they are always
  // added to the form.
  foreach ($views as $info) {
    if (isset($fields[$info['name'] . '_' . $info['display']])) {
      _eva_build_extra_fields($form, $entity_type, $entity, $fields, $info['name'], $info['display'], 'form');
    }
  }
}