Evan Lee
Evan Lee

Reputation: 758

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?

Upvotes: 3

Views: 3430

Answers (1)

RusAlex
RusAlex

Reputation: 8575

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.

Upvotes: 2

Related Questions