Jump to:

23380 Posts in 18311 Topics by 2867 members

General Questions

SilverStripe Forums » General Questions » CurrencyField problem

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 1227 Views
  • jamesg
    Avatar
    Community Member
    8 Posts

    CurrencyField problem Link to this post

    Hi,

    I'm using Silverstripe 2.4.0 for a project at the moment and I am using a couple of CurrencyFields on a particular page type in the CMS.

    Unfortunately I am unable to save the page as I keep getting the following javascript error:

    $("Form_EditForm").validateCurrency is not a function

    Has anyone else encountered this? and does anyone know of a fix?

  • jamesg
    Avatar
    Community Member
    8 Posts

    Re: CurrencyField problem Link to this post

    Additional info:

    Currently have recreated this in Firefox 3.6.8 and the most recent version of Chrome on Mac OS X.

    It only seems to be a problem when the CMS loads straight to that page (eg. if I click that page in the CMS and then refresh I will get the javascript error). However, if I load the CMS on a different page and then click on the page in question, I get no errors and it saves fine.

  • Matze0681
    Avatar
    Community Member
    25 Posts

    Re: CurrencyField problem Link to this post

    got the same problem. could u solve it ?

    cheers
    matze

  • vancouverWill
    Avatar
    Community Member
    121 Posts

    Re: CurrencyField problem Link to this post

    I have this same issue, seems to be more of a bug than just a problem. Did any of you get this resolved?

    cheers

  • ampedup
    Avatar
    Community Member
    133 Posts

    Re: CurrencyField problem Link to this post

    To add to this. I have the same problem.

    The problem is in:
    sapphire\forms\CurrencyField.php

    function:
    function jsValidation()

    particuallarly the regex pattern match:
    /^\s*(-?\\\$?|\\\$-?)?(\d{1,3}(\,\d{3})*|(\d+))(\.\d{2})?\s*\$/

    To recreate this problem create a CurrencyField in your page. Select that page in the CMS. Refresh the page in your browser. In the firebug console you will notice the error:
    invalid quantifier

    Then when saving the page the following error occurs:
    $("Form_EditForm").validateCurrency is not a function

    When you change the regex it no longer throws errors (although it no longer correctly validates against what it should).

  • ampedup
    Avatar
    Community Member
    133 Posts

    Re: CurrencyField problem Link to this post

    I found changing the regex to the following worked:
    /^\s*[\$]?(\d{1,3}(\,\d{3})*|(\d+))(\.\d{2})?\s*\$/

    1227 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.