You are here

function _fc_field_attach_form in Field Complete 7

Implements hook_field_attach_form().

1 call to _fc_field_attach_form()
fc_field_attach_form in ./fc.module
Implements hook_field_attach_form().

File

./fc.form.inc, line 115
Field Complete - Provides field-based completeness for any entity - admin.

Code

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

  // Must check that there are fields first: https://drupal.org/node/2049945
  if (empty($form_state['field'])) {

    // No fields so let's just get out of here.
    return;
  }
  foreach ($form_state['field'] as $field_name => $field_data) {

    // We have to use the field language here, not the entity language.
    if (!empty($form[$field_name]['#language'])) {
      $langcode = $form[$field_name]['#language'];
    }
    if (empty($field_data[$langcode])) {

      // No field data for the current language
      continue;
    }
    $instance = $field_data[$langcode]['instance'];
    if (!empty($instance['settings']['fc']['fc_include']) && !$instance['deleted'] && !empty($form[$field_name])) {

      // Add my after build function
      $form[$field_name][$langcode]['#after_build'][] = 'fc_field_attach_after_build';
    }
  }
  $form['#pre_render'][] = 'fc_form_pre_render';
}