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.

Values of hidden fields are posted

  1. bartv2
    Member

    I've set up some conditional category select fields:

    1: Select type A or B

    show only if type=A: 2: Select category type 1

    show only if type=B: 3: Select category type 2

    The user interface works great, but I find that values of hidden category select fields are posted and stored, which can potentially leave 'dirty' information in my database.

    A scenario to recreate this:

    - Select type A
    - Field 2 is shown, select a category
    - Select type B
    - Field 2 is hidden, field 3 is shown. Select a category
    - Submit the form

    Now values for both field 1,2 and 3 are submitted and stored.

    Thanks!

    Bart

    Posted 14 years ago on Thursday February 25, 2010 | Permalink
  2. I'd have to look at your form setup if you can provide us with a WordPress admin login via our Contact Us form.

    Conditional fields that aren't displayed are not supposed to have their data saved. Testing locally this was the case, so i'd have to see what you are doing differently with your form setup to determine what is going on.

    Posted 14 years ago on Thursday February 25, 2010 | Permalink
  3. bartv2
    Member

    Hi Carl,

    I didn't have time to look into this until now. After diving into the code, I did find that all post category information is saved, regardless of it's display state (as a result of conditional logic).

    In the file forms_model.php in the function get_post_fields(), I inserted the following code right before the switch statement to check if the field should be saved or not, and things work fine now.

    if( RGFormsModel::is_field_hidden($form, $field, array()) ) {
    	break;
    }
    
    switch($field["type"]){

    Can you verify is this is a correct solution and if so, include it in the next release?

    Cheers,

    Bart

    Posted 14 years ago on Saturday April 3, 2010 | Permalink
  4. bartv2
    Member

    Line 3 should be 'continue', sorry.

    Posted 14 years ago on Saturday April 3, 2010 | Permalink
  5. Thanks! We will look into it and see about adding it or another fix to the next release.

    Posted 14 years ago on Sunday April 4, 2010 | Permalink