Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Custom form doesn't work

Our old forums are still available as a read-only archive.

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

Page: 1
Go to End
Author Topic: 1907 Views
  • mobius
    Avatar
    Community Member
    54 Posts

    Custom form doesn't work Link to this post

    Hi,

    This is in 2.0.1rc6.

    I have a custom form, the code to build it looks like this:

    class ContactPage_Controller extends Page_Controller {

    function Form() {
    return new Form($this, "ContactForm", new FieldSet(
    // List the your fields here
       new TextField('SenderName'),
       $this->ContactName,
          $this->ContactEmail,
    new EmailField("Email", "Email address")
    ), new FieldSet(
    // List the action buttons here
    new FormAction('doSendEmail', 'Submit')

    ), new RequiredFields(
    // List the required fields here: "Email", "FirstName"
    ));
    }
    function doSendEmail($data, $form){
    die('not yet implemented');
    }
    }

    Which looks like it should be fine, however I get an error message:

    Fatal error: Call to a member function setForm() on a non-object in **siterootremoved**/www/sapphire/forms/Form.php on line 37

    Any ideas?

  • mobius
    Avatar
    Community Member
    54 Posts

    Re: Custom form doesn't work Link to this post

    never mind. This is a bug in my code, not yours ;)

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