On unlimited value fields a button 'Add another item' is used to add an unlimited number of values for that field. Is there any way I could just enter a custom number of values when creating a node as opposed to clicking the Add another item button?

Sure we can define a fixed number of values under field settings but I'm facing a scenario where I need to define a custom number of a multi-value field upon node creation, then the fields will automatically load itself based on that custom number that I just defined, you know instead of me clicking the Add another item button several times.

Comments

tatha.bh’s picture

As I understand you need to dynamically change the field numbers like in one form it may be 5 and in another it may be 10. Right?

halloffame’s picture

Yes that is correct. To further explain it... Only one field is added everytime we click the 'Add another item' button. If we need 5 values for that field we need to click the Add another item button 4 times (1st one is already pre-loaded). I'm looking for a solution where the Add another item button generates a specific number of field based on an input from another field. Possible?

An ajax callback is triggered when we hit the Add another item button to load one field each time we click it. Can we somehow adjust this callback using hook_form_alter (or other hooks) and load an x number of fields defined on another field?

osopolar’s picture

Did you find a solution for that?

W.M.’s picture

I am looking for a way to open on initial form load a certain number of empty fields. Any idea how to do this?