I'm trying to create form with 3 different '#multiadd' elements on it. When doing so it seems that only the last element rendered actually works. The other two get an "Add" button but clicking it does nothing.

It appears that when there are multiple elements on the page and they all use the same text for the "Add" button it doesn't know which button was clicked. Should probably add a #name property to the add/remove buttons.

Comments

eojthebrave’s picture

Status: Active » Needs review
StatusFileSize
new1.04 KB

This should fix it. Adds a unique #name property the add/remove buttons.

sidharth_k’s picture

Title: Avoid the use of different #add_text and #remove_text for multiple multiadds on same page » Does not work when used multiple times on the same form.
Assigned: sidharth_k » Unassigned
Status: Fixed » Needs review

Yes, this problem was encountered by me previously and the way I solved it (i.e. more than 1 multiadd required on same page) is that you need to create a unique

#add_text
#remove_text

property on the multiadd. As long as the text is different for all three buttons you won't encounter any problems. Does this patch give us any advantage to method above?

sidharth_k’s picture

Cool... I played around with it. Its now possible to have buttons with the same text on multiadds on the same page. Previously if there were 2 or more multiadds we needed to give them different #add_text and #remove_text to prevent the clashing you described above.

sidharth_k’s picture

Title: Does not work when used multiple times on the same form. » Avoid the use of different #add_text and #remove_text for multiple multiadds on same page
Assigned: Unassigned » sidharth_k

This has been committed to the 6.x-1.x-dev branch

Thanks!

sidharth_k’s picture

Status: Needs review » Fixed

Title: Does not work when used multiple times on the same form. » Avoid the use of different #add_text and #remove_text for multiple multiadds on same page
Assigned: Unassigned » sidharth_k
Status: Needs review » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.