[[+content_image]]
I
I
Ilya Beloborodov2017-06-15 11:32:07
Yii
Ilya Beloborodov, 2017-06-15 11:32:07

Why is one field not validated?

public function rules(){
 return [
   [['name', 'last_name', 'email', 'phone'], 'required'],
 ];
}

and in the view
<?= $form->field($model, 'name')->textInput(['placeholder' => Utils::placeholder($model, "name")])->label(false); ?>
<?= $form->field($model, 'last_name')->textInput(['placeholder' => Utils::placeholder($model, "last_name")])->label(false); ?>
<?= $form->field($model, 'phone')->textInput(['placeholder' => Utils::placeholder($model, "phone")])->label(false); ?>
<?= $form->field($model, 'email')->textInput(['placeholder' => Utils::placeholder($model, "email")])->label(false); ?>

The field last_nameis ignored by the validator. Tell me what the problem is, this is the first time

Answer the question

In order to leave comments, you need to log in

[[+comments_count]] answer(s)
I
Ilya Beloborodov, 2017-06-15
@kowap

The problem was with the use of scripts. didn't notice

M
Maxim Timofeev, 2017-06-15
@webinar

does not validate or ignore? Allows you to write an empty value? Then you need to look at the model. And a controller. For example, somewhere in beforeSave or beforeValidate there is logic that manipulates it. Maybe there are gaps? Lots of options. I advise you $model->save()to do it after var_dump($model->last_name)and check what is there in real life.
There is definitely a reason, there are a lot of options, but there is too little data to say anything specific.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question