Jump to:

10994 Posts in 2728 Topics by 1819 members

All other Modules

SilverStripe Forums » All other Modules » Trouble with submitting a custom form.

Discuss all other Modules here.

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

Page: 1
Go to End
Author Topic: 805 Views
  • szymon23
    Avatar
    Community Member
    3 Posts

    Trouble with submitting a custom form. Link to this post

    Hello everyone!

    I've just spent about four hours of my life trying to get a simple form to submit. And it wouldn't... I wrote a huge long post here, pleading for some help on the matter only to find the solution (what?! it was that simple?!) by accident myself.
    Perhaps the subject has been explained, but I just can't go to bed without sharing this info with anyone who might get as desperately stuck as I did tonight.

    Goal: create a simple custom form (I wanted to format it a little, hence the customization).

    So, I followed the Forms page in the doc.
    Created my own subclass of Form, a template for it, defined the fields and so on.

    Here's the mine that I stepped on... in the controller of the Page class on which I wanted to create my form, i wrote a function:

    function NewCustomForm() {
          return new myCustomForm($this, 'RF');
    }


    can you see it already?
       
    and of course the appropriate $NewCustomForm call in the template as well.

    And nothing happens when I submit the form! Why? jQuery.form returns the whole HTML of my page, WTH????

    I don't think this is in the Forms tutorial and I think it should be, I was miserable for hours ;)

    THE NAME OF THE FUNCTION THAT CREATES THE FORM HAS TO BE THE SAME AS THE NAME OF THE FORM!!! AS IN:

    function NewCustomForm() {
          return new myCustomForm($this, 'NewCustomForm');
    }

    Hope nobody ever gets stuck on that one.

    All the best!

    Szymon, Poland

    805 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.