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

Yii 2 Kartik input validation message is coming while clicking the browse button only

'import-pdf', 'options' => ['enctype' => 'multipart/form-data'], ]); ?>
Rahm
  • 3
  • 4
0
votes
1 answer

Capturing Google Analytics events on validation failures in YII2

In our YII app, we would like to capture google analytics on validation failures. We are using modal rules for validating our data. Here is one of our validation modal code snippet public function rules() { return [ ['email',…
Alex
  • 1,406
  • 2
  • 18
  • 33
0
votes
1 answer

Yii2 : how to check value is unique with below scenario

my table and its data id |type | email 1 |1 | user1@domain.com 2 |1 | user2@domain.com 3 |2 | user3@domain.com 4 |2 | user4@domain.com 5 |2 | user5@domain.com Their is lots of type 1,2,3,4,5,.. All TYPE has dublicate…
0
votes
1 answer

yii2 ajax validation does not show errors

I have ActiveForm in a widget, and want to validate it fields(get errors under the field) without reloading the page. But the best result, i have got is the json with errors from validating action.'ValidateOn..' - seems that they arent work at all,…
DannyP1
  • 15
  • 6
0
votes
1 answer

yii2 file required custom validation

I have a form where the required validation rules for the fields can be configures and stored in the model. When rendering the form, I create the validation rules as follows (simplified) which works fine. $view_parameters =…
crafter
  • 6,246
  • 1
  • 34
  • 46
0
votes
1 answer

Yii2 model rules match validation

In model rules I have this rule: [ ['field1', 'field2,] 'match', 'pattern' => "/^[а-яА-ЯіІїЇєЄa-zA-Z\s\`\'\-\,]*$/u", ] On form submit this rule works fine. But on client side it's not working. In console I see error: Uncaught SyntaxError:…
neolodor
  • 75
  • 1
  • 7
0
votes
1 answer

Save multiple selections from a listbox - Yii2

I have made a Listbox depend on a dropDownList, when selecting an option from the dropDownList brings me a list of data that is added to the Listbox, it works to save a single option but the problem occurs when trying to save multiple selections, I…
Miguel Angel
  • 55
  • 10
0
votes
1 answer

How can I valid random names fields in Yii?

I have a lot of fields generated from loops. I would like to validate them through validation rules (integer). I don't know how to throw so many fields with random names into the model to the rules () function. How can I validate fields without a…
0
votes
2 answers

Unable to access attributes values in Dynamic Model validation Yii2

I am trying to validate user input. $params = Yii::$app->getRequest()->getBodyParams(); $model = new DynamicModel($params); $model->addRule(['userId', 'category', 'type'], 'required'); $model->addRule('userId',…
Raheel
  • 8,716
  • 9
  • 60
  • 102
0
votes
1 answer

how to addError function in yii2 model

i want make form for change password, with field old password and new password like this field($model, 'old_password')->textInput()->label('Old Password ') ?> field($model,…
eniac05
  • 477
  • 4
  • 10
  • 23
0
votes
1 answer

How to customize validation error message to display on tooltip in Yii2?

I am using ActiveForm of yii2 and I want to customize the validation errors. I want to display errors on tooltip. This is my form 'login-form','method'=>'post']); ?> field($model,…
php guy
  • 113
  • 13
0
votes
2 answers

Yii2 Ajax Modal Post With Ajax Validation Works But Model Does Not save

There are many suggestions to begin the controller code with this: if (Yii::$app->request->isAjax && $model->load(Yii::$app->request- >post())) { Yii::$app->response->format = Response::FORMAT_JSON; return…
MichaelMcD
  • 31
  • 5
0
votes
2 answers

Yii2 Add additional attribute data-image in DropDownList options

I trying to add attribute "data-image"="image" path in tags of dropdownList I want to this: