I can see no example how to properly use field_multiple_value_form or equivalent. is there anything like that documented anywhere?

I'm not sure if it should be in Form or in Field example.

Comments

mile23’s picture

Status: Active » Postponed (maintainer needs more info)

The first place to look is always api.drupal.org: http://api.drupal.org/api/drupal/modules%21field%21field.form.inc/functi...

This says that it's only ever called once in core, in order to generate the AHAH widget form with multiple values and an 'add more' button.

Basically it seems to be part of the Field API.

Did you have a specific example need?

Mołot’s picture

Any example how to create many-valued form field. Like if we don't know how many strings user will provide or how many files is he going to upload. I kinda don't want to reinvent the wheel again.

mile23’s picture

For any field you implement with Field API, Drupal can automatically turn it into a multi-valued field based on user settings. It does this with (among others) field_multiple_value_form().

Try it: Add a field to a node. In the field settings, near the bottom, you'll see a 'Number of values' dropdown. Set this to 'unlimited.' Now add content and see the nice multi-value form Drupal made, with the 'add another item' button and draggable rows.

It accomplishes this with AHAH. Each item within the list is another form generated by the field widget implementation.

So I'm not sure what else needs to be demonstrated for handling multiple values, since the API does that for you.

Did you have something else in mind?

Mołot’s picture

Yep I have something else in mind. In my module's configuration form I need to ask user for allowed MIME types. I can parse space separated strings all right, but it's error prone. I wanted to add multi-value text field there. Not to a node.

iconify’s picture

Did you find a solution for using multi-value forms in a module? I'm looking for an example of the same thing.

Thanks.

arpitr’s picture

Issue summary: View changes
jungle’s picture

Status: Postponed (maintainer needs more info) » Closed (outdated)

No activity for over 7 years. I am closing this. Please feel free to reopen if necessary.

Thanks!