1778 Posts in 581 Topics by 555 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1616 Views |
-
form validation on cms page

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.
Thanks!
-
Re: form validation on cms page

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
-
Re: form validation on cms page

15 December 2009 at 8:12pm Last edited: 15 December 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
from:
$form = new Form($this, "EditForm", $fields, $actions);
to:
$validator = ($record->hasMethod('getCMSValidator')) ? $record->getCMSValidator() : null;
$form = new Form($this, "EditForm", $fields, $actions, $validator);
| 1616 Views | ||
|
Page:
1
|
Go to Top |

