drupal-7drupal-fields

Multiple field groups with empty fields


I'm trying to make this working

 [Title Field] [Link Field]

 [Add More values] // Will add a [Title Field] [Link Field]

But for example the first [Title Field] is having the value: Foo. With a link to http://foogle.fo Then I click on [Add More values], and a new row of a group field is showing. In this row I only write in the [Link Field].

When I save this, it will also save the right connection between Title and Link field. But how could I possibly print this in a loop, like this print_r($node->field_titel); this will only return one field (that one with a value), I also want the empty one so I could fetch the links connected to each title.

See image for clearer information about the field groups. An example of multiple field So if there would be a third row, the second row would not fetch the second Beskrivning value, it will fetch the third Beskrivning. Because the object $node->field_beskrivning Will not return any empty results.

So, what I want is a $node->field_beskrivning with the empty rows in right order or any other examples of solutions.


Solution

  • You can try Field Collection module

    The Field Collection module is the successor to the CCK3 Multigroup. It allows a set of fields to be combined together and treated as a single field. For example, a field collection named Playlist can be created consisting of the text fields Song and Artist. When a Playlist entry is created the Song and Artist fields are presented together as elements of the Playlist field.