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.

All other Modules /

Discuss all other Modules here.

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

Trouble with submitting a custom form.


Reply


819 Views

Avatar
szymon23

Community Member, 3 Posts

14 July 2009 at 11:33am

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 [url=http://doc.silverstripe.org/doku.php?id=form&s=custom%20form]Forms[/url] 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