Domanda

I've got a form that's being generated using the Form API. There is a fieldset that contains several text fields. What I need to do is have a link or button that a user clicks if they want to add a duplicate of that fieldset to the form so they can add another set of similar information to the form. This is to essentially allow them to add multiple records without having to add each record individually. Is there a good way to go about adding this kind of functionality using the Forms API in Drupal 7?

È stato utile?

Soluzione

There's a good example of this in the examples module package:

http://api.drupal.org/api/examples/ajax_example%21ajax_example_graceful_degradation.inc/function/ajax_example_add_more/7

It's a little complex, but that is very well documented, so you should be able to follow along.

You'll want to look at the entire ajax_example module (part of http://drupal.org/project/examples) for the relevant menu callbacks as well.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top