1

It's the first time I have been using a "money" field and don't really know how to use it. The docs don't tell much about it so I ask for help here.

To get the value including a currency symbol, I can use the | money filter. But how can I get the value only? I want to use it with a frontend form and therefore need the value only. Of course I could use the replace filter but that seems like a hacky workaround to me.

Further, if I enter the value "100" in the frontend form and save an entry, it becomes "1".

Is there an easy way to make handling money values work with frontend forms or would it be better to change the field to a number field?

1 Answer 1

1

A little late I know, but as noted in my answer here, Money fields have an amount property that (with a little reformatting) you can use to display the value wherever you need it.

Further, if I enter the value "100" in the frontend form and save an entry, it becomes "1".

Money fields store values as cent/hundredths. So to store 100 you need to pass 10000 as the value from your form

2
  • Thanks for your response. This makes working with Entry Forms a bit "complicated". But I solved it with a "helper input". I set the type of the input for the money field to "hidden" and add one more input where the money value can be set. I use JS to monitor if the value of the helper input changes and if so, I get the value, multiply it by 100 and set the new value for the hidden input.
    – obs
    Apr 27 at 18:47
  • Yeah unfortunately that's probably the only way to go unless you want to use a custom controller and do the conversion there. At time of writing, there's very little documentation about using Money Fields - def something P&T could improve
    – Tom Davies
    Apr 28 at 10:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.