For example I have such forms:
class ArticleForm extends sfFormDoctrine
{
public function setUp()
{
$this->setWidgets(array(
'id' => new sfWidgetFormInputHidden(),
'title' => new sfWidgetFormInput(array(), array('size'=>80)),
'teaser' => new sfWidgetFormTextarea(),
'body' => new sfWidgetFormTextarea(),
'is_review' => new sfWidgetFormInputCheckbox(),
));
$this->setValidators(array(
'id' => new sfValidatorDoctrineChoice(array('model' =>
'Article', 'column' => 'id', 'required' => false)),
'title' => new sfValidatorString(array('required'=>true,
'max_length'=> 255)),
'teaser' => new sfValidatorString(array('required'=>true)),
'body' => new sfValidatorString(array('required'=>true)),
'is_review' => new sfValidatorString(),
));
$this->embedForm('review', new ArticleReviewForm($this-
>getObject()->getReview());
}
public function getModelName() { return 'Article'; }
}
class ArticleReviewFrom extends sfFormDoctrine
{
public function setUp()
{
$this->setWidgets(array(
'rating' => new sfWidgetFormInput(array(),
array('size'=>2)),
'opposite_comment' => new sfWidgetFormTextarea(),
'opposite_author' => new sfWidgetFormInput(array(),
array('rel'=>'stUserAdmin/autocomplete')),
'opposite_rating' => new sfWidgetFormInput(array(),
array('size'=>2)),
));
$this->setValidators(array(
'rating' => new sfValidatorNumber(array('min'=>0,
'max'=>10, 'required'=>false)),
'opposite_comment' => new
sfValidatorString(array('max_length'=> 5000, 'required'=>false)),
'opposite_author' => new
sfValidatorDoctrineChoice(array('query'=> $author,
'column'=>'nickname', 'model'=>'stUser', 'required'=>false)),
'opposite_rating' => new sfValidatorNumber(array('min'=>0,
'max'=>10, 'required'=>false)),
));
}
public function getModelName()
{
return 'ArticleReview';
}
}
What is the best way to implement on two forms like this such
conditional validators:
If is_review in ArticleForm is set, rating from ArticleReviewForm is
required.
If one of opposite_ fields is set, the other ones are required.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---