• Hi Jules

    I am developing the pluing CF7 Smart-grid layout extension and there is an issue with the validation of hidden (required) fields. The method,

    function remove_hidden_post_data($posted_data) {
            $this->set_hidden_fields_arrays($posted_data);
    
            foreach( $this->hidden_fields as $name => $value ) {
                unset( $posted_data[$name] );
            }
    
            return $posted_data;
        }
    

    in the class ContactForm7ConditionalFields (file cf7cf.php) is removing the hidden fields from the cf7 posted data, however, I believe you should be using the $value variable which holds the field name rather than the $name variable which is simply the index of your $this->hidden_fields array.

    Removing the hidden (unused) fields allows me to skip over the unused fields as I am hooking the wpcf7_validate to validate more complex field inputs which cf7 is unable to handle properly.

    Correct me if I am wrong, but I think this is bug, cause otherwise I don’t see the purpose of the method.

    thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Jules Colle

    (@jules-colle)

    You could be right.. my mind is blown somewhat though, because I was pretty sure that I designed the plugin so that hidden data does not get removed on form submission. So the not-functioning of this function is by design. I really wonder why I have put it there in the first place then. I feel a bit hesitant about fixing this bug, because this is actually how some people would expect the plugin to work.

    I think I will include a checkbox in the admin interface, which is disabled by default: “Do not submit hidden fields”, and then fix this function accordingly.

    This still will not fix your problem I assume, because most people will leave this option unchecked. Is there something else I could do? Add a filter somewhere so you could check which fields are hidden?

    Thread Starter Aurovrata Venet

    (@aurovrata)

    Hi Jules

    thanks for looking into this so promptly,

    So the not-functioning of this function is by design. I really wonder why I have put it there in the first place then. I feel a bit hesitant about fixing this bug, because this is actually how some people would expect the plugin to work.

    haha, indeed I know exactly the feeling.

    This still will not fix your problem I assume, because most people will leave this option unchecked. Is there something else I could do? Add a filter somewhere so you could check which fields are hidden?

    yes, indeed, that would be the next best thing. Could you include a filter a to call this very same function? Currently you have,

    add_filter( 'wpcf7_posted_data', array($this, 'remove_hidden_post_data') );

    so maybe you could an extra filter,

    add_filter( 'wpcf7cf_filter_posted_data', array($this, 'remove_hidden_post_data') );

    I could then apply this filter when I am checking the validation, and obtain a data array of actual fields to check.

    thanks.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Possible BUG: hidden fields not removed from cf7 posted data’ is closed to new replies.