Closed (outdated)
Project:
Examples for Developers
Version:
7.x-1.x-dev
Component:
Form Example
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
6 May 2013 at 07:53 UTC
Updated:
18 Feb 2023 at 17:57 UTC
Jump to comment: Most recent
Comments
Comment #1
mile23The 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?
Comment #2
Mołot commentedAny 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.
Comment #3
mile23For 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?
Comment #4
Mołot commentedYep 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.
Comment #5
iconify commentedDid you find a solution for using multi-value forms in a module? I'm looking for an example of the same thing.
Thanks.
Comment #6
dev.paulson commentedhttp://rapiddg.com/blog/use-ajax-support-multiple-item-values-custom-dru...
Comment #7
arpitr commentedComment #8
jungleNo activity for over 7 years. I am closing this. Please feel free to reopen if necessary.
Thanks!