Jump to:

2002 Posts in 1422 Topics by 616 members

Form Questions

SilverStripe Forums » Form Questions » 2 email forms on one page

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

Page: 1
Go to End
Author Topic: 1109 Views
  • HanSolo
    Avatar
    Community Member
    83 Posts

    2 email forms on one page Link to this post

    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
  • Willr
    Avatar
    Forum Moderator
    5490 Posts

    Re: 2 email forms on one page Link to this post

    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?

  • lx
    Avatar
    Community Member
    82 Posts

    Re: 2 email forms on one page Link to this post

    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.

  • Willr
    Avatar
    Forum Moderator
    5490 Posts

    Re: 2 email forms on one page Link to this post

    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.

    1109 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.