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.060 seconds

Really great Joomla tool Cook is a great piece of kit for creating Joomla components. It uses a drag-n-drop interface to build tables and fully featured pages. You can test your component in a sandbox before downloading it packaged up ready to install. The developer is responsive on the support forum.
Twev (JED)
          

Get Started