You are here

function bricks_field_attach_form in Bricks​ 7.5

Implements hook_field_attach_form().

File

./bricks.edit.inc, line 18

Code

function bricks_field_attach_form($entity_type, $entity, &$form, &$form_state, $langcode) {
  if (module_exists('treeable')) {
    return;
  }

  // Determine the list of instances to iterate on.
  list(, , $bundle) = entity_extract_ids($entity_type, $entity);
  $instances = field_info_instances($entity_type, $bundle);

  // Iterate through the instances and collect results.
  foreach ($instances as $instance) {
    $field_name = $instance['field_name'];
    $field = field_info_field($field_name);
    if (_bricks_field_is_treeable($field) && $instance['widget']['type'] !== 'inline_entity_form' && ($field['cardinality'] > 1 || $field['cardinality'] == FIELD_CARDINALITY_UNLIMITED)) {
      $field_language = $form[$field_name]['#language'];
      $form[$field_name][$field_language]['#theme'] = 'bricks_tree_value_form';
    }
  }
}