Author image
Senior Developer

Custom add another

Drupal 7 fields are great, but using multiple valued fields and field collection you can quickly reach the point of having a form that looks like this:

A complex field collection form

In this contrived example I've got two field collections and a multi-valued 'Links' field within that.

Although it's reasonably clear what clicking 'Add another item' will do in each case, when the form is full of data it can become less so.

We can give content editors a helping hand by changing the buttons from 'Add another item', to something more useful like 'Add another carousel item' etc. With the Custom add another module we can do just that. We can make that form look like this:

A complex field collection form with customised butons

Now it's much clearer what clicking on one of those buttons will do.

Comments

Whereas this is without a doubt a great tip and usability enhancement I am often weary of installing yet another module to do something that could be just as easily accomplished using a simple form_alter() in a custom module I already have :)

Sure, that's the wonderful choice that you have with Drupal. Though this module is only around 80 lines of code, so it's hardly a heavyweight, and it does give you a UI and do it to all the multiple valued fields, not just a single case.

This is great.

I agree with Alex that it might make sense to be added via form_alter() in a custom module, and for some cases I'll probably go that route.

However, it's nice to know that this module is on the lighter side of things, and that it has a UI that allows for 'per bundle' settings.

Comments on this article are now closed, if you want to give us feeback you can use our contact form instead.