You are here

function multifield_field_attach_form in Multifield 7.2

Same name and namespace in other branches
  1. 7 multifield.field.inc \multifield_field_attach_form()

Implements hook_field_attach_form().

File

./multifield.field.inc, line 469
Field integration for the Multifield module.

Code

function multifield_field_attach_form($entity_type, $entity, &$form, &$form_state, $langcode) {
  foreach (field_info_instances($entity_type, $form['#bundle']) as $field_name => $instance) {
    $field = field_info_field($field_name);
    if (multifield_extract_multifield_machine_name($field) && $field['cardinality'] == FIELD_CARDINALITY_UNLIMITED && !empty($field['settings']['hide_blank_items']) && field_access('edit', $field, $entity_type)) {
      $element_langcode = $form[$field_name]['#language'];
      if ($form[$field_name][$element_langcode]['#max_delta'] > 0) {
        $form[$field_name][$element_langcode]['#max_delta']--;
      }
    }
  }
}