Projet

Général

Profil

Révision 560c3060

Ajouté par Julien Enselme il y a plus de 8 ans

Update ctools 1.7 -> 1.9

Voir les différences:

drupal7/sites/all/modules/ctools/plugins/content_types/form/entity_form_field.inc
57 57
    }
58 58
  }
59 59

  
60
  if (module_exists('field_group')) {
61
    foreach ($entities as $entity_type => $entity) {
62
      foreach ($entity['bundles'] as $type => $bundle) {
63
        if ($group_info = field_group_info_groups($entity_type, $type, "form")) {
64
          foreach ($group_info as $group_name => $group) {
65
            if (!isset($types[$entity_type . ':' . $group_name])) {
66
              $types[$entity_type . ':' . $group_name] = array(
67
                'category' => t('Form'),
68
                'icon' => 'icon_field.png',
69
                'title' => t('Group form: @widget_label', array('@widget_label' => $group->label)),
70
                'description' => t('Field group on the referenced entity.'),
71
              );
72
            }
73
            $content_types[$entity_type . ':' . $group_name]['types'][$type] = $bundle['label'];
74
          }
75
      }
76
      }
77
    }
78
  }
79

  
60 80
  // Create the required context for each field related to the bundle types.
61 81
  foreach ($types as $key => $field_content_type) {
62 82
    list($entity_type, $field_name) = explode(':', $key, 2);
......
85 105
  $ids = entity_extract_ids($entity_type, $entity);
86 106
  $field = field_info_instance($entity_type, $field_name, $ids[2]);
87 107

  
88
  // Do not render if the entity type does not have this field.
89
  if (empty($field)) {
108
  // Check for field groups.
109
  if (empty($field) && module_exists('field_group')) {
110
    $groups = field_group_info_groups($entity_type, $entity->type, "form");
111
    $group = !empty($groups[$field_name]) ? $groups[$field_name] : NULL;
112
  }
113

  
114
  // Do not render if the entity type does not have this field or group.
115
  if (empty($field) && empty($group)) {
90 116
    return;
91 117
  }
92
  $block = new stdClass();
93 118

  
119
  $block = new stdClass();
94 120
  if (isset($context->form)) {
95 121
    $block->content = array();
96
    $block->content[$field_name] = $context->form[$field_name];
97
    unset($context->form[$field_name]);
122
    if (!empty($field)) {
123
      $block->content[$field_name] = $context->form[$field_name];
124
      unset($context->form[$field_name]);
125
    }
126
    else {
127
      // Pre-render the form to populate field groups.
128
      if (isset($context->form['#pre_render'])) {
129
        foreach ($context->form['#pre_render'] as $function) {
130
          if (function_exists($function)) {
131
            $context->form = $function($context->form);
132
          }
133
        }
134
        unset($context->form['#pre_render']);
135
      }
136

  
137
      $block->content[$field_name] = $context->form[$field_name];
138
      unset($context->form[$field_name]);
139
    }
98 140
  }
99 141
  else {
100 142
    $block->content = t('Entity info.');

Formats disponibles : Unified diff