Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC:

$19.95 loads as .95 in a form edit in the backend 16 Mar 2013 07:07 #6945

I am using text fields in my table and if I enter $19.95 in the form, it is saved properly in the database and is the proper value in a var_dump from within the view.html.php for that form but within the displayed form, it is truncated to .95.

It appears as if it is a dollar sign escape issue as if you do not use it as the first character, it works properly.

I have reproduced it in a virgin project within the sandbox so it is not influenced by my version of joomla or anything on my servers.

Edit: V2.5 Compatibility selected.

Please Log in or Create an account to join the conversation.

Last edit: by agaudreau. Reason: Info missing

Re: $19.95 loads as .95 in a form edit in the backend 16 Mar 2013 09:20 #6947

The problem resides in the generated dom.php within the parse() function.

$html = preg_replace("/<%" . strtoupper($key) . "%>/",$value, $html);

should be:

$html = preg_replace("/<%" . strtoupper($key) . "%>/", str_replace("$","\\$",$value), $html);

in order to escape $'s in $value to prevent preg_replace() from removing the '$xx' from a passed in value of '$xx.xx'.

I see several calls to preg_replace() within your generated code so you should escape them as well in order to prevent problems elsewhere in your code.

Please Log in or Create an account to join the conversation.

Re: $19.95 loads as .95 in a form edit in the backend 16 Mar 2013 09:32 #6948

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
Hi @agaudreau and welcome!

Good find! Karma++

I would suggest though, if you are storing prices to use a decimal field and not a string to ensure data integrity for calculations that you will probably need to do in the future. It would just be a case of prepending the '$ ' to the value to display to the user.

Hope this helps!

Gez
Need help with your Cook/Joomla Project? . PM me to find out what I can help with. NO time wasters please!!!

Please Log in or Create an account to join the conversation.

Re: $19.95 loads as .95 in a form edit in the backend 19 Aug 2013 18:39 #10833

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
Finally fixed.

Thank for you patience.
Coding is now a piece of cake

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Time to create page: 0.083 seconds

I jumped and started to work on a demo component... but 2 days later this demo component became the real component. I just showed today the end result to my customer and he turned to me and said... "this is more than I expected"... All of this is because Cook did cut about 70% of my work and provided me more ways to improve the usability of the component. The end result was 17 tables all related between than to generate a full dashboard for the travel agents. Thanks for Cook developers for such great tool. This component would not be possible to be done at short time with all the features in it
Griiettner (Forum)  

Get Started