Hi,
How do I validate and show an error on a custom text field?
My form field:
<?= Html::input('text','password1','', $options=['class'=>'form-control', 'maxlength'=>10, 'style'=>'width:350px']) ?>
<?= Html::input('text','password2','', $options=['class'=>'form-control', 'maxlength'=>10, 'style'=>'width:350px']) ?>
My validation:
$request = Yii::$app->request;
$password1 = $request->post('password1');
$password2 = $request->post('password2');
if($password1 != $password2)
{
//echo "This is an error";
//$this->addError('error','Passwords dont match.');
$this->addError('request', 'The country must be either.....');
}
The problem is when setting the addError. How do I do that if the text field is not part of the model?