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.

TypeError: value.replace is not a function

  1. Hello,

    I've got this javascript error while trying to edit one of my fields :

    Erreur : TypeError: value.replace is not a function
    Fichier Source : http://localhost/wp-admin/admin.php?page=gf_edit_forms&id=1
    Ligne : 3283

    I'm using the following version of GravityForms :

    Version PHP 5.3.6
    Version MySQL 5.5.9
    Version de WordPress 3.5.1
    Version de Gravity Forms 1.6.12

    And the field is a select prepopulated with Gravity Forms + Custom Post Types (http://wordpress.org/support/plugin/gravity-forms-custom-post-types)

    It looks like the error comes from GetFieldChoices in js.php, line 866 you do this :
    var value = field.enableChoiceValue ? field.choices[i].value : field.choices[i].text;

    which in my case returns a number (the id of my custom post type), thus value.replace is undefined for Int typed variables.

    Just replace this line with the following (cast to string) and we are good to go :
    var value = field.enableChoiceValue ? String(field.choices[i].value) : field.choices[i].text;

    Any chance to see this error fixed in a next release ?

    Posted 11 years ago on Friday March 8, 2013 | Permalink
  2. David Peralty

    Thanks for the report. I'll pass it on to our developers to look at.

    Posted 11 years ago on Friday March 8, 2013 | Permalink
  3. Thanks for the heads up! We will make this adjustment. You will see it in 1.7 Beta 2.

    Posted 11 years ago on Monday March 11, 2013 | Permalink

This topic has been resolved and has been closed to new replies.