G
G
grepfreecd grepfreecd2015-10-02 07:58:26
Yii
grepfreecd grepfreecd, 2015-10-02 07:58:26

How in Yii to accept values ​​through the post "0" or 0, but at the same time so that the field is not empty?

There was a problem. There is a text field in which you need to accept a monetary amount, the format must be double.
The rules stated the following:

return array(
array('moneyField','type','type=>'float'),
array('moneyField','required')
);

As soon as I send '0', the validator gives an error, saying that the field is not filled. I tried to set a filter, previously substituting the value "00", the validation passed, but in the model attributes, the value is still null, as soon as I send a number greater than zero, everything is fine.
required I add dynamically, I take the data of fields and their types from SOAP. Honestly, I'm tired of solving such a simple task. Help me please.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
pantsarny, 2015-10-03
@pantsarny

required remove
'moneyField', 'numerical', 'min' => 0, 'allowEmpty' => false

A
Alexey Tsarapkin, 2015-10-02
@Dreamka

Try

0.00

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question