2011-06-26 13 views

答えて

1

あなたが...例えば、フォームを検証するためにコールバックを使用する必要があります。

public function configure() 
{ 
    $this->widgetSchema['email'] = new sfWidgetFormInput(); 
    $this->validatorSchema['email'] = new sfValidatorEmail(array('required' => true)); 

    $this->validatorSchema->setPostValidator(
    new sfValidatorCallback(array('callback' => array($this, 'postValidate'))) 
); 
} 

public function postValidate($validator, $values)  
{ 
    // only run the post validator if the email has passed validation 
    // if it hasn't passed validation, it will be blank and we can skip this 
    if ($values['email']) 
    { 
    $v = new myPostValidator(); 
    $v->clean($values); 
    } 

    return $values; 
} 
0

それはあなたが「通常」と事後検証で何を意味するかによって異なります。

if ($form->isValid()) { // code here before and after the save(); } 

それとも、アクションでpostExecuteを使用します:あなたは条件を使用することができますアクションクラスで

+0

"通常の"バリデータは各ウィジェットに添付されたバリデータであり、ポストバリデータはsetPostValidator()で設定されたバリデータです。 – tamir

関連する問題