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.

Form Questions /

2 email forms on one page


Reply


4 Posts   1191 Views

Avatar
HanSolo

Community Member, 83 Posts

20 November 2010 at 4:19am

I wonder if it is possible to have 2 different forms on one page.
I ahve installed the userforms module and I can add one form to the page but i do want 2 differnt forms.

See my attached image how I would like it to look like, or do anyone have another solution to it?

Attached Files
Avatar
Willr

Forum Moderator, 5513 Posts

23 November 2010 at 9:51pm

UDF doesn't support multiple forms on a page, you would need to write your own forms (or at least one) like http://doc.silverstripe.org/tutorial:3-forms.

Or you could change that design to have form. Whats the difference between the two?

Avatar
lx

Community Member, 83 Posts

14 December 2010 at 12:24pm

Hi Willr,

I have a simmilar problem, because I want to have many forms on a page (without using UDF).

A function e.g.

public function listUsers() { ... } returns a DataObjectSet of Users.
These users are listed on the Page and displayed with jQueryUI Accordion (thats why having 10 forms on the same Page doesnt look bad)
So if I click on a User additional information is shown and I also get a contactform for this user.

The form is a property of the DataObjectSet:

public function listUsers() {
...
foreach ($users AS $user) {
$fieldset = new Fieldset(...);
$actions = new FieldSet(
new FormAction('userContactSend', 'send')
);

$user->contactForm = new Form($this, "what in here?", $fieldset, $actions);
}
}

My problem is the second param of the form-class.

Normally you would have a method in your code that returns this form, like in tutorial 3:

return new Form($this, 'BrowserPollForm', $fields, $actions);

In my case all forms are build within the function listusers().
So, if i fill a form out a form and click "send" i get a blank form and the information is lost.

Hopefully someone has solved this before.

Avatar
Willr

Forum Moderator, 5513 Posts

14 December 2010 at 3:05pm

what in here?

That is the name of the function you are currently in. Whatever you put in there needs to be the name of a function which returns the exact form.

When you submit a form in SilverStripe it call's the function in that space *before* passing it to the userContactSend() function so it is important.