0
On my table Escola
I have another associated table called EscolaPercentual
.
And I have a form that has data of the 2 tables, when saving in my action I give a SaveAll
in the Model School, which has $hasMany
for the modeno EscolaPercentual
, so he saves what is Escola
in Escola
and what is EscolaPercentual
in the same.
The problem is that when I edit, if I do not rewrite all the data that are decimal numbers on EscolaPercentual
, the database does not accept and is all 999.99.
In the School percentage model, I debugged using beforeSave
to see how the data was going, and found that 20.00
as it was being presented in my form, but when I debugged I saw that 20.00
, turned out to be 2000
and the database turned it into 999,99
since I set the column to double.
What’s in
EscolaPercentual
?999,99
would be the default value if no one is informed? seems to have some function diverting your main code.– rray
Yes, the problem is that the behavior that treated this does not work with saveAll, so I treated the values with beforeValidate, using str_replace at the points for comma.
– Michel Henriq
Put this str_replace code
– rray
public function beforeValidate($options = array()) {
 
 $this->data[$this->alias]['percentual'] = str_replace('.', ',', $this->data[$this->alias]['percentual']);
 return true;
 
 }
– Michel Henriq
In the bank the tab for pennies is the point, you need to do the reverse, change touch for comma per point.
– rray