Dondariadmin (トーク | 投稿記録) |
Dondariadmin (トーク | 投稿記録) |
||
67行目: | 67行目: | ||
), array('halt_on_error' => true) | ), array('halt_on_error' => true) | ||
)); | )); | ||
+ | |||
+ | [[Category:PHP]] | ||
+ | [[Category:symfony]] |
class hogeForm extends BaseForm { public function configure() { $this->setWidgets(array( 'age_from' => new sfWidgetFormInputText(), 'age_to' => new sfWidgetFormInputText(), )); $this->getValidatorSchema()->setPostValidator( // '<='等の比較演算子文字列は、sfValidatorSchemaCompareクラス内に定数宣言もありますが、このほうが分かりやすいように思います。 new sfValidatorSchemaCompare('age_from', '<=', 'age_to') ); $this->getWidgetSchema()->setNameFormat('hogeinput[%s]'); $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema); } }
class hogeForm extends BaseForm { public function configure() { $this->setWidgets(array( 'age_from' => new sfWidgetFormInputText(), 'age_to' => new sfWidgetFormInputText(), 'work_length_from' => new sfWidgetFormInputText(), 'work_length_to' => new sfWidgetFormInputText(), )); $this->setValidators(array( 'age_from' => new sfValidatorInteger(), 'age_to' => new sfValidatorInteger(), 'work_length_from' => new sfValidatorInteger(), 'work_length_to' => new sfValidatorInteger(), )); $this->getValidatorSchema()->setPostValidator(new sfValidatorAnd(array( new sfValidatorSchemaCompare('age_from', '<=', 'age_to'), new sfValidatorSchemaCompare('work_length_from', '<=', 'work_length_to'), ))); $this->getWidgetSchema()->setNameFormat('hogeinput[%s]'); $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema); } }
$this->getValidatorSchema()->setPostValidator(new sfValidatorAnd(array( new sfValidatorSchemaCompare('age_from', '<=', 'age_to'), new sfValidatorSchemaCompare('work_length_from', '<=', 'work_length_to'), ), array('halt_on_error' => true) ));Tweet