Home » YII Ad hoc validation

YII Ad hoc validation

by Online Tutorials Library

Ad hoc Validation

To validate values that are not bound to any model, we need to use ad hoc validation. Or if you want to validate values without models then use ad hoc validation.

To perform one type of validation, you may call yiivalidatorsvalidator() method of the desired validator.

Not all the valdiators support this type of validation.

For example, we are calling yiivalidatorsDateValidator()

But to perform multiple validations, against several values you can use yiibaseDynamicModel which defines both attributes and rules.

For example, here we are calling DynamicModel to validate date and email.

On the browser, pass the URL

http://localhost/ad_hoc/frontend/web/index.php?r=site/ad-hoc-validation

YII Ad hoc validation 1

Look at the above output, both date and email have been validated at the same time.

You may also like