Questions tagged [yii2-validation]

Use this tag if your question relates to the Yii2-validation-system, no matter if your validation is within a model or as standalaone validator-instances.

This tag is about the Yii2-validation-system. In most cases validators get used within models to validate their properties (rules()-method). However, you can also use all the validators as standalone instances or create your own inline-validators.

The basic usage of Yii2's validators is very well documented in the corresponding section of the official guide.

155 questions
-1
votes
1 answer

Yii2, why a model validation fails due to a missing mandatory attribute when that attribute is assigned by a Behavior?

I have a Model with a [['creation_time'], 'integer'] attribute which have a [ 'class' => TimestampBehavior::className(), 'createdAtAttribute' => 'creation_time' ] behavior assigned. If I mark this attribute as required it'll fail the model…
-1
votes
1 answer

validation if other fields not empty

In the form, I have three fields: family, name and patronymic. It is necessary to set up the validation in such a way that if at least one of them was filled, the others also became required. If not one is not completed, then the validation must be…
triest23
  • 1
  • 4
-1
votes
1 answer

Custom validation on DynamicFormWidget in Yii2 not working

I am trying to add a custom validation for a DynamicFormWidget widget in Yii2. There is a DynamicFormWidget widget 'percentage' and the sum total of all 'percentage' values dynamically created should be 100. I added a validation rule public…
user7282
  • 5,106
  • 9
  • 41
  • 72
-2
votes
1 answer

how to keep selected value on Yii2 html::dropddownlist?

i have the following code in my view: all(),'region','region'),[ 'prompt' => 'Select Region..','style'=>'width:200px',]) ?> and submit button
1 2 3
10
11