Jump to:

2012 Posts in 1438 Topics by 621 members

Form Questions

SilverStripe Forums » Form Questions » form validation on cms page

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

Page: 1
Go to End
Author Topic: 2006 Views
  • Ben_W
    Community Member
    80 Posts

    form validation on cms page Link to this post

    Hi, I have added three fields in a page named, FanchisePage. Pretty straight forward.

    $fields->addFieldToTab('Root.Content.Main', new TextField('Headline'), 'Content');
          $fields->addFieldToTab('Root.Content.Main', new TextField('Phone'), 'Content');
          $fields->addFieldToTab('Root.Content.Main', new EmailField('Email'), 'Content');

    what I would like to know is, how may I validate this form, when user fill in value in the back end cms area? Let's say, I need make Headline and Email as mandatory field.


  • abmcr
    Community Member
    2 Posts

    Re: form validation on cms page Link to this post

    I am absolute beginner with Silverstripe.... and i also have this question
    How it is possible to use a validator for a field add with

    $fields->addFieldToTab('Root.Content.Main', new TextField('Author'), 'Content');

    Thank you

  • dvp
    Community Member
    4 Posts

    Re: form validation on cms page Link to this post

    As i know in CMSMain validators are supportted from SS 2.4.0 alpha1 by defining getCMSValidator() function in Page object.

    In prior versions you can patch CMSMain->getEditForm() function and change Form creation
    $form = new Form($this, "EditForm", $fields, $actions);
    $validator = ($record->hasMethod('getCMSValidator')) ? $record->getCMSValidator() : null;
    $form = new Form($this, "EditForm", $fields, $actions, $validator);

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.