Hi everyone
This is an odd one, as on some dataobjects its working fine, however here is an example bit of code of it not working. It simply doesnt show the validation, i can even put a die() in there and still it passes. So i guess its just not listening to my class?
Any ideas?
<?php
class TextStatement extends DataObject {
private static $db = array(
'PersonName' => 'Varchar',
'Testimonial' => 'Text',
"DateSent" => "Date",
'SortOrder' => 'Int'
);
// One-to-one relationship with gallery page
private static $has_one = array(
'HomePage' => 'HomePage'
);
// tidy up the CMS by not showing these fields
public function getCMSFields() {
$fields = parent::getCMSFields();
$fields->removeByName('DateSent');
$enquiry = new DateField('DateSent', 'Date');
$fields->removeFieldFromTab("Root.Main","HomePageID");
$fields->addFieldToTab('Root.Main', $enquiry->setConfig('showcalendar', true));
return $fields;
}
// Tell the datagrid what fields to show in the table
private static $summary_fields = array(
'PersonName' => 'PersonName' ,
'Testimonial' => 'Testimonial',
"DateSent" => "DateSent"
);
public function getCMSValidator() {
return new TextStatement_Validator();
}
public function getValidator() {
return new TextStatement_Validator();
}
}
class TextStatement_Validator extends RequiredFields {
function php($data) {
$bRet = parent::php($data);
if (empty($data['PersonName'])) {
$this->validationError('PersonName','Persons name is required',"required");
$bRet = false;
}
if (empty($data['Testimonial'])) {
$this->validationError('Testimonial','Testimonial is required',"required");
$bRet = false;
}
if (empty($data['DateSent'])) {
$this->validationError('DateSent','Date sent is required',"required");
$bRet = false;
}
if (empty($data['EnquiryEmailsTo'])) {
$this->validationError('EnquiryEmailsTo','EnquiryEmailsTo is required',"required");
$bRet = false;
}
return $bRet;
}
}