Answer the question
In order to leave comments, you need to log in
How to solve the problem of validation in Yii2?
Hello!
I have one problem.
the problem is that when submitting the form does not skip an application that does not have the require attribute
, when clicking on the submit, it will simply ask you to upload a file (but I don’t need it, you need to validate if you uploaded a file, and if you didn’t upload it, you just need to skip it) how to do this?
public $uploadFile;
public function rules(){
return [
[['id','date','phone'], 'integer'],
[['name','phone'], 'required'],
[['name'], 'string', 'max' => 20],
[['company','file'], 'string', 'max' => 255],
[['uploadFile'], 'file', 'skipOnEmpty' => false, 'extensions' => 'pdf, cdr, zip, rar'],
];
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question