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
3
votes
3 answers

How to create a directory inside a directory in yii2 and upload file into that directory

I have a form ['enctype' => 'multipart/form-data']]); ?> field($userformmodel, 'user_image')->fileInput(); ?> 'btn btn-primary']) ?> …
3
votes
1 answer

Yii2 AccessControl giving Forbidden 403 when using HTTPBearerAuth in Rest API

I am authenticating on my base controller using HTTPBearerAuth public function behaviors() { $behaviors['authenticator'] = [ 'class' => CompositeAuth::className(), 'authMethods' => [ HttpBearerAuth::className(), …
learner
  • 391
  • 1
  • 2
  • 11
3
votes
2 answers

Protected Directory existence and creating custom validator in Yii2

I was searching for password strength meter for Yii2. I found this article for Yii1. I saw protected directory mention there. I'm unable to find this folder. Is it available in Basic Application Template or Advanced Application Template?
Nana Partykar
  • 10,556
  • 10
  • 48
  • 77
3
votes
2 answers

Yii2, custom validation: clientValidateAttribute() doesn't work correctly

I have form, created by ActiveForm widget. User enters polish postal code there. In appropriate controller I put entered data in DB, for example: $company_profile_data->postal_code =…
Boolean_Type
  • 1,146
  • 3
  • 13
  • 40
2
votes
1 answer

yii2 Error of dynamic client validation URL - Cannot read property 'test' of undefined

I add a field dynamically using jquery and then dynamically add the field to the validation list as shown in the link (Adding and removing fields dynamically). In my code, I add url validation. function validateDynamicField() { …
pavel
  • 91
  • 1
  • 9
2
votes
1 answer

how to place yii2 form error in title of anchor tag

how to place yii2 form error in title of anchor tag This is my code $form = ActiveForm::begin([ 'id' => 'login-form', 'options' => ['class' => 'form-horizontal'], 'fieldConfig' => [ 'template' => ' {label} …
2
votes
1 answer

Yii2 unique validator ignored

In the rules() of my RegisterForm model: [ 'user_username', 'unique', 'targetClass' => 'app\models\User', 'message' => 'This username is already been taken.' ], In my controller: $model = new RegisterForm(); if ( $model->load(…
keeg
  • 3,990
  • 8
  • 49
  • 97
2
votes
2 answers

Validate Yii2 Activeform on simple button click

I want to validate my Yii2 activeform on simple button click which is not submitButton. I tried $('#formId').yiiActiveForm("validate") but it is not working. I also tried - $('#formId').yiiActiveForm('submitForm') it validates form but it also…
Ninja Turtle
  • 1,293
  • 2
  • 24
  • 50
2
votes
1 answer

Yii2 required validator in an array field

In my code I have a field (e.g. field name is exampleField[]) in which I implemented add more functionality through JS. Now, I want to implement Yii2 required Validator on each field. I already use each validator but it's not working. My yii2…
SAR
  • 57
  • 8
2
votes
2 answers

Yii2 Unique Validator not working when insert so fast

I am using ActiveRecord model to save data. Unique Validator works very perfect. But when i insert data so fast, it no longer works perfectly. In some request i get error that it can not catch by Yii. Integrity constraint violation –…
Ngô Văn Thao
  • 3,671
  • 1
  • 20
  • 24
2
votes
0 answers

Yii2 oauth2 client_credential token authentication

I use Filsh/yii2-oauth2-server, I can use client token using $_pos to access my API. In controller: if (!isset($_post['token'])){ //exeption } else{ token = $_post('token'); } if ((Accesstokens::isAccessTokenValid($token))) { // do some thing. } in…
Jimmy
  • 21
  • 1
2
votes
1 answer

Validating unique email using DynamicFormWidget - Yii2

I am using DynamicFormWidget for multiple input fields like: first_name, last_name, email & mobile_no. And, I don't want user to type the existing email. Means, email should be unique. It is working when I am not using DynamicFormWidget. Actually, I…
Nana Partykar
  • 10,556
  • 10
  • 48
  • 77
2
votes
1 answer

Yii2 Validation rule: How to check datetime and place does not collidate with another entry?

This is my table event As you see Transaction 1 time_begin: 2016-03-10 07:00:00 time_end: 2016-03-10 08:00:00 place: 1 If user makes a Transaction 2 and then selects time_begin: 2016-03-10 07:15:00 time_end: 2016-03-10…
2
votes
2 answers

targetAttribute (Or something similar) for required validator (Yii2)

So, here is my scenario. I have got a model called URL. URL has the following attributes: link (required), scheme (required, but not safe.scheme is parsed from the link) and a few other attributes as well, which are not in context to this…
Gogol
  • 3,033
  • 4
  • 28
  • 57
2
votes
3 answers

Yii2 validate Bank Account number and Routing number

I want to validate Bank Account number(123456789) and Routing number(434344343), with custom message=>Please enter 12 digit valid account number.(000123456789) I used number validator, integer but not working as I expecting. Validator should checks…
Muhammad Shahzad
  • 9,340
  • 21
  • 86
  • 130
1
2
3
10 11