E
E
EvgMul2015-10-22 22:00:31
Yii
EvgMul, 2015-10-22 22:00:31

Yii model how to specify optional field?

Hello. The following code is located in the rules of the model: array('file', 'file', 'types'=>'jpg, gif, png'),
If the field with the file is left empty in the form and the form is submitted, then the following error appears in the array of saving errors in the database [file] => Array
(
[0] => File cannot be blank .
)
this rule is.
Can you please tell me how to indicate that this field is optional and can be empty?
Thanks in advance to all who respond.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
EvgMul, 2015-10-22
@EvgMul

For a very long time I could not find a solution, so I wrote here, but after 5 minutes I still found it.
Need to specify'alloEmpty' => true

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question