Note that there are some explanatory texts on larger screens.

plurals
  1. POsymfony/doctrine custom validation
    text
    copied!<p>I am struggling with the custom validation in symfony/doctrine. I made three widgets:</p> <ul> <li>sfWidgetFormDateTimeAmPm,</li> <li>sfWidgetFormDateAmPm and</li> <li>sfWidgetFormTimeAmPm to add the am/pm to the standard 24 hours date/time format. </li> </ul> <p>Similar I created three validator classes:</p> <ul> <li>sfValidatorDateTimeAmPm,</li> <li>sfValidatorDateAmPm and</li> <li>sfValidatorTimeAmPm.</li> </ul> <p>I added this classes to my doctrine basic class like this:</p> <p>class EventForm extends BaseEventForm {</p> <pre><code> public function configure(){ parent::configure(); /* custom widget */ $this-&gt;widgetSchema['start_date'] = new sfWidgetFormDateTimeAmPm(); $this-&gt;widgetSchema['end_date'] = new sfWidgetFormDateTimeAmPm(); $this-&gt;widgetSchema['repeat_end_after_date'] = new sfWidgetFormDateTimeAmPm(); $this-&gt;widgetSchema['created_at'] = new sfWidgetFormDateTimeAmPm(); $this-&gt;widgetSchema['updated_at'] = new sfWidgetFormDateTimeAmPm(); $this-&gt;setValidators['start_date'] = new sfValidatorDateTimeAmPm(); $this-&gt;setValidators['end_date'] = new sfValidatorDateTimeAmPm(); $this-&gt;setValidators['repeat_end_after_date'] = new sfValidatorDateTimeAmPm(array('required' =&gt; false)); $this-&gt;setValidators['created_at'] = new sfValidatorDateTimeAmPm(); $this-&gt;setValidators['updated_at'] = new sfValidatorDateTimeAmPm(); $this-&gt;validatorSchema-&gt;setPostValidator( new sfValidatorDoctrineUnique(array('model' =&gt; 'Event', 'column' =&gt; array('id'))) ); $this-&gt;widgetSchema-&gt;setNameFormat('event[%s]'); $this-&gt;errorSchema = new sfValidatorErrorSchema($this-&gt;validatorSchema); </code></pre> <p>... but it does not work. Could someone advice me. I have no clue, what it did wrong or what I have forgotten to do.</p> <p>Thanks Andreas</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload