2011-07-26 18 views
0

symfony/doctrine에서 사용자 정의 유효성 검사에 어려움을 겪고 있습니다. 표준 24 시간 날짜/시간 형식으로 AM/PM을 추가symfony/doctrine 사용자 정의 유효성 확인

  • sfWidgetFormDateTimeAmPm,
  • sfWidgetFormDateAmPm 및
  • sfWidgetFormTimeAmPm : 나는 3 위젯을했다.

    • sfValidatorDateTimeAmPm,
    • sfValidatorDateAmPm 및
    • sfValidatorTimeAmPm : 유사

    나는 세 가지 유효성 검사기 클래스를 만들었습니다.

내가 이렇게 내 교리의 기본 클래스에이 클래스를 추가 :

클래스 EventForm는 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); 

를 확장 ... 그러나 그것은 작동하지 않습니다. 누군가가 조언을 해줄 수 있었 을까? 나는 단서가 없다, 그것이 잘못되었거나 내가 잊어 버린 것을 가지고있다.

답변

1

$this->setValidators['field']이 잘못

감사 안드레아스, 당신은 $this->validatorSchema['field'] = new WhateverValidator()을 원한다.

관련 문제