Reputation: 2678
I am struggling with the custom validation in symfony/doctrine. I made three widgets:
Similar I created three validator classes:
I added this classes to my doctrine basic class like this:
class EventForm extends BaseEventForm {
public function configure(){
parent::configure();
/* custom widget */
$this->widgetSchema['start_date'] = new sfWidgetFormDateTimeAmPm();
$this->widgetSchema['end_date'] = new sfWidgetFormDateTimeAmPm();
$this->widgetSchema['repeat_end_after_date'] = new sfWidgetFormDateTimeAmPm();
$this->widgetSchema['created_at'] = new sfWidgetFormDateTimeAmPm();
$this->widgetSchema['updated_at'] = new sfWidgetFormDateTimeAmPm();
$this->setValidators['start_date'] = new sfValidatorDateTimeAmPm();
$this->setValidators['end_date'] = new sfValidatorDateTimeAmPm();
$this->setValidators['repeat_end_after_date'] = new sfValidatorDateTimeAmPm(array('required' => false));
$this->setValidators['created_at'] = new sfValidatorDateTimeAmPm();
$this->setValidators['updated_at'] = new sfValidatorDateTimeAmPm();
$this->validatorSchema->setPostValidator(
new sfValidatorDoctrineUnique(array('model' => 'Event', 'column' => array('id')))
);
$this->widgetSchema->setNameFormat('event[%s]');
$this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);
... but it does not work. Could someone advice me. I have no clue, what it did wrong or what I have forgotten to do.
Thanks Andreas
Upvotes: 0
Views: 388
Reputation: 60413
$this->setValidators['field']
is wrong, you want $this->validatorSchema['field'] = new WhateverValidator()
.
Upvotes: 1