PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Quantity needs a valid number: but it is!

  1. Carlo
    Member

    Hi, I've setup all the plugin and it goes to PayPal correctly (I'm still in sandbox mode now). The problem is with the product field. I have dinamically populated name and price and it seems ok.
    In the form, as test user, I insert the quantity and submit: the form tells that I need to insert a valid value! If i submit again (without changing the value) it works. How could it be?? Thanks!

    Posted 13 years ago on Sunday April 24, 2011 | Permalink
  2. Are you using PHP and custom code to dynamically populate form data?

    Posted 13 years ago on Monday April 25, 2011 | Permalink
  3. Carlo
    Member

    Yes I am. I have several products but I need one form.

    Posted 13 years ago on Monday April 25, 2011 | Permalink
  4. Okay, the issue is going to be how you are dynamically populating the field(s). Can you post your custom code so we can take a look? Use http://pastie.org and post a link to the code snippet.

    The way the Pricing Fields work is it checks the values against what the form is setup to use to insure users aren't tampering with the values. Depending on how your custom code was written, it's going to trigger this and think it's been tampered with. It's a security measure.

    Posted 13 years ago on Monday April 25, 2011 | Permalink
  5. Carlo
    Member

    ok, here it is the page template i'm using for the form:
    http://pastie.org/1845098

    in the form edit, i checked "Allow field to be populated dynamically" and i used:
    Name: prodotto
    Price : prezzo
    Quantity: quantita

    Note that i'm in phase 1: I inserted a value in the populate function.
    I wanted to pass to phase 2 (dinamically pass a value depending on a post custom field) when phase 1 works.
    Thank you very much!

    Posted 13 years ago on Thursday April 28, 2011 | Permalink
  6. You are very close. The validation is getting triggered by the price, not the quantity. The reason is that the price value needs to be currency formatted. See below

    Replace

    add_filter("gform_field_value_prezzo", "populate_prezzo");
    function populate_prezzo($value){
    	return 550;
    	}

    With

    add_filter("gform_field_value_prezzo", "populate_prezzo");
    function populate_prezzo($value){
    	return GFCommon::to_money(550);
    }
    Posted 13 years ago on Friday April 29, 2011 | Permalink
  7. Carlo
    Member

    Thank you Alex, that was a doubt I had.
    I changed the code but the form still says that I have to insert a valid number...

    Posted 13 years ago on Saturday April 30, 2011 | Permalink
  8. Interesting. It worked well on my local install. If you send me a WP login to alex@rocketgenius.com, I will be happy to take a closer look.

    Posted 13 years ago on Sunday May 1, 2011 | Permalink
  9. Hi
    This post is almost what I need and I have it working on my form BUT...

    How can I pass a the $value variable to the function.
    I want to use:
    return GFCommon::to_money($value)

    I'm setting $value is a pre-form php case statement based on a GET (url) variable.
    It all works fine IF is use:
    return GFCommon::to_money(550)
    and sets the form price to £550.00

    Thanks in advance
    Steve

    Posted 13 years ago on Wednesday May 25, 2011 | Permalink