1

I wanted to a content type which get number of title and links. And I want an option which allows the user to add more title and links. The fields in the content type are

   1. Promotional Image
   2. Image Alternative Text
   3. Title
   4. Links

In the above mentioned field. I wanted to group only the Title and Links field. I wanted to give add more option for those two fields alone. Can anyone tell me how this could be done. I cant establish a link between those two fields. At present when I select the 'number of values' option in field settings it gives me add more button to each field but I am not able to link those two fields with any relation. Can anyone please suggest me a solution?

3

If you want to group fields together to be accessible as a single field on your form, the easiest way is using the Field Collection module. It:

Provides a field-collection field, to which any number of fields can be attached.

Using that you can group your Title and Links fields into one, and you'll have an 'Add more' button for the group, rather than for each individual field widget.

  • It worked well. I could use the field collection through UI but I need to create the field collection. but I need to create the entire content type programmatically. I have no problem creating the fields programmatically but field collection doesn work if I do the way I do for other fields. – Drupal Developer Apr 7 '12 at 14:30
  • link This is how I create the content type for your kind information. – Drupal Developer Apr 7 '12 at 14:32
  • Have a look at Creating field collection programatically, it should have all the information you need – Clive Apr 7 '12 at 14:32
  • The link you gave me tells us how to create field collection but what is need is how to add fields to this field collection programmatically? – Drupal Developer Apr 7 '12 at 15:11
  • I dont understand the second part of the code which actually adds the fields to the collection. – Drupal Developer Apr 7 '12 at 15:21
0

Check this too; Field Group module:

Fieldgroup will, as the name implies, group fields together. All fieldable entities will have the possibility to add groups to wrap their fields together. Fieldgroup comes with default HTML wrappers like vertical tabs, horizontal tabs, accordions, fieldsets or div wrappers.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.