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.

Form Questions /

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

form validation on cms page

Go to End

3 Posts   2489 Views


Community Member, 80 Posts

16 March 2009 at 2:23pm

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.



Community Member, 2 Posts

19 November 2009 at 11:18pm

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


Community Member, 6 Posts

15 December 2009 at 8:12pm

Edited: 15/12/2009 8:13pm

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);