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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Form Questions /

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

RequiredFields not validating


Go to End


1205 Views

Avatar
quanto

Community Member, 91 Posts

27 June 2013 at 12:17am

Hi

I'm trying to create a custom form in Silverstripe 3.0, but the RequiredFields ar not working. I have no idea what i'm doing wrong:

class Product_Controller extends Page_Controller {
  static $allowed_actions = array('contactForm');

  public function init() {
    parent::init();
  }

  public function contactForm(){
    return Form::create($this, 'Form', 
      new FieldList(
        new TextField('Naam', '', 'Naam'),
        new TextField('Emailadres', '', 'E-mail'),
        new TextField('Telefoon', '', 'Telefoonnummer'),
        new FormAction('zendForm', '>>') 
      ), new FieldList(), new RequiredFields(array('Email', 'Telefoon'))
    ); 
  }
}