Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Form Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Multiple instances of the same form


Go to End


3 Posts   1984 Views

Avatar
zard

Community Member, 25 Posts

9 October 2014 at 10:30pm

Hi,

For my use, I need to replicate the same form on a page multiple times. I've tried setting the HTMLID of the form in order for validator messages to work correctly, however, I was unable to get it to work.

Is there any guidance on how to work with multiple instances of the same form on a single page?

Avatar
zz

Community Member, 16 Posts

26 June 2015 at 8:12pm

Bump. Is this possible?
For example I have some .ss

..
<% loop Items %>
  $ItemForm($Attributes)
<% end_loop %>
..

May I have this approach or I have to do this just with one form or multiple different forms?

Avatar
Pyromanik

Community Member, 419 Posts

27 June 2015 at 2:38am

Edited: 27/06/2015 2:40am

It is possible.
Change the form name before returning it, and also do not forget to re-set the FormAction to the original value.
This will change the HTML ID attributes (should do both form and fields), and keep the form submitting to the same location.

http://api.silverstripe.org/3.1/class-Form.html#_setName
http://api.silverstripe.org/3.1/class-Form.html#_setFormAction