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.

150 questions
0
votes
1 answer

how to disable any dropdown field when update the from in yii2?

Here I'm stuck with one point when I open any form than i want to enable to choose one dropdown but if I want to update that from this dropdown field will be disabled. So Which syntax I put in the form? $form->field($model, 'branch_id',…
0
votes
3 answers

Yii 2 file input renders hidden file input tag

I am using yii2 to build a simple application with a signup feature. Problem is when I render a file input tag using active forms, it render a file input field and a hidden field. The validator then picks the one which is hidden and always says that…
Noor Ahmed
  • 1,357
  • 7
  • 14
0
votes
2 answers

Yii2 Model Rules Update Checking Rules For Same Record

I.E. If i update address_line1 then its giving error for mobile number allocated. While update it should not match with it self. Even if i change mobile number it should check with other user. public function rules() { return [ …
Santosh
  • 393
  • 2
  • 11
0
votes
5 answers

YII2 Custom validation is not working with custom function model rule

I am trying to implement with custom function in model its not working i am not getting what's wrong in my code. i am trying to call with basic later i will put my condition. Here is model code public function rules() { return [ …
Santosh
  • 393
  • 2
  • 11
0
votes
1 answer

Yii2 write-only property

I need some help with my project. I have a user table in my db. I have connected this table to a User model. And I have a user-create form with several inputs. In this form I have a password field, and when I want to submit my form I make from this…
Francis
  • 869
  • 1
  • 7
  • 14
0
votes
0 answers

Yii2 radio button validation is not working

I have a form with multiple reference for a class(I mean table) in single form like add more details. Main goal of the task is a company have more than one users. each user have some access restrictions. so while adding company we will add multiple…
Manikandan S
  • 774
  • 1
  • 7
  • 16
0
votes
1 answer

how can I validate data in yii2 manually?

I wrote a function that creates a 6-digits number. how can I validate this number manually without using models in yii2?
mojtaba.sln
  • 51
  • 1
  • 7
0
votes
1 answer

Yii2 ajax validate and submit form

I have very little AJAX's Information. That's why I asked my question here... in yii2 how can create and submit form with ajax validation? So I searched but could not find the right solution... for example: (according to the official training…
Mahdi
  • 35
  • 2
  • 6
0
votes
1 answer

Yii2 validators don't show message

Can someone tell me what i am doing wrong here? // Some other validation rules [['FILE_BLOB'], 'file' , 'maxSize' => 1024 * 1024, 'message' => 'Here goes my message'], //Some more validation rules Well my problem is that validator works fine, but…
arccuks
  • 172
  • 1
  • 12
0
votes
2 answers

Yii2 model custom rules and validations for attribute which is array

Being trying to sort this out but going nowhere with it. I have got an array as attribute for a model and I am trying to create custom validation for some of the keys in the array as required. Or even can't figure out how the attribute labels will…
Think Different
  • 2,785
  • 1
  • 10
  • 18
-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
  • 3
-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,146
  • 8
  • 38
  • 67
-1
votes
2 answers

How to cache "exists" validation in Yii2

I'm trying to cache the db calls for Yii2 exists validation, but can't work out where to initiate it. Because I'm using a multi-model form with a lot of relations, the overhead is getting a little too much. Any ideas?
Tom Horwood
  • 328
  • 3
  • 13
-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
9
10