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
0
votes
1 answer

yii2 modal attribute as required dynamically

I have a case where a field is mandatory, but not always mandatory. If I write the attribute as required in modal rules() like: [['my_attribute'], 'required'] then it would make the field required in every case. can I make a specific modal's…
Danish Ahmed
  • 171
  • 1
  • 9
0
votes
0 answers

Why does CSRF get validated when executing console command in Yii2

I'm trying to run a background process. my idea is, execute a command in php which in turn run the console Yii2. $result = exec('php yii controller/action param param > result.log &'); In Localhost everything works great, but the server does not…
Alfredo Gt
  • 174
  • 1
  • 10
0
votes
3 answers

Yii2 renderPartial clientSide validation doesn't work

renderPartial clientSide validation doesn't work. I want to render part of form with ajax. Ex.: _form.php $form = ActiveForm::begin([ 'options' => [ 'enableAjaxValidation' => true, ] ]); $form->field($model,…
user3185208
  • 47
  • 1
  • 1
  • 7
0
votes
1 answer

Yii 2.0 - Error Message in Minimum Number Validation In Yii2.0

I am having trouble locating the error message of the Minimum Number Validation.. i tried overwriting it with this code public function rules() { return [ [['login_name'], 'string', 'min' => 5, 'message' => 'Please input…
ii--L--ii
  • 207
  • 1
  • 7
  • 23
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,507
  • 9
  • 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
  • 1,775
  • 2
  • 12
  • 15
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
  • 902
  • 1
  • 8
  • 18
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
  • 33
  • 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
  • 173
  • 2
  • 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,815
  • 1
  • 12
  • 18
-1
votes
1 answer

Yii2 - Show/Hide Fields on Form based on dropDown selection on form

I am new to Yii2 and have been trying to work out how to hide/show certain fields on the form based on a dropDownList selection with client-side validation. Basically I have a model and form view that collects information relating to 'candidates'…
1 2 3
10
11