Money function but what if it is empty?
Ello, In the documentation i am reading there is a money function but if the value isn't a int or float you get a error,
Is there anyway if the field is empty you could disable the function or something in that way
10 Replies
this is my code if it is empty there will come a '-' for in the place but then i get that error
What's the error?
Quin, sounds like you are storing your data as a string, so the model returns the value as a string.
You need to cast price as int or float on the model.
something like this?
yeah
doesn't change the fact that i am still using the '-' if it is empty right?
It will as you can't output - in the column when using money as money is formatting it
If you want to format it then remove money() and just replicate what money does in the condition instead.
You are fighting between money values and a string you see
Aah yeah that's also a option ty! will share the code when i am done]
Solution
Final result π