Reply: Validating Input

NOTE: You are posting the message as a 'Guest', you can not edit the message or delete it
Please Log in or Register to skip this step.
X

Topic History of: Validating Input

Max. showing the last 6 posts - (Last post first)

1 year 6 months ago
Validating Input

$model = new \app\models\ContactForm();

// populate model attributes with user...

Validating Input

As a rule of thumb, you should never trust the data received from end users and should always validate it before putting it to good use.

Given a model populated with user inputs, you can validate the inputs by calling the [[yii\base\Model::validate()]] method. The method will return a boolean value indicating whether the validation succeeded or not. If not, you may get the error messages from the [[yii\base\Model::errors]] property. For example,

Read more...