Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Yii: How to validate a form field? It can be null, but can not empty

Yii: How to validate a form field? It can be null, but can not empty.

For example, I have a Book Model. When I do a form submitting, some of the fields can be null(not set), But It should not empty.

How to check it?

like image 737
Evan Lee Avatar asked Dec 18 '25 09:12

Evan Lee


1 Answers

Yes you can, just not use that field in "required" validator, and use for this field any other, like "numeric" or some another validator. It will do a trick for you.

like image 103
RusAlex Avatar answered Dec 19 '25 22:12

RusAlex



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!