• Resolved NickD76

    (@nickd76)


    I have an optional file upload field which displays if someone chooses the option to upload their own data set.

    However, if the user chooses to have us provide the data set for them, the upload field remains hidden. In this case the product cannot be added to card and the file upload field fires it’s “validation failed message”. This should not occur, since the file upload field is not even set to “required”!

    Even if it was set to required, it would be logical behaviour for “required” to be overridden on fields that are hidden. (Allowing a way to use conditional required based on visibility).

    • This topic was modified 6 years, 3 months ago by NickD76.
    • This topic was modified 6 years, 3 months ago by NickD76.

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Plugin Contributor sarkparanjothi

    (@sarkparanjothi)

    Sorry for the Improper validation. just now i realise this issue thank you for mention it. i’ll fix on wcff next release.

    If you want immediate solution just do it.

    open wc-fields-factory/includes/wcff-validator.php from your website plugin directory

    line number 42

    Before $this->validate_product_fields(); line

    $this->remove_field_rule_is_hidden(); add this on and below the validate method add following codes.

     /* To remove unwanted fields from product field */
        private function remove_field_rule_is_hidden(){
            for( $x = 0; $x < count( $this->product_fields ); $x++ ){
               foreach ( $this->product_fields[$x] as $fields) {
                   if( isset( $fields["field_rules"] ) && count( $fields["field_rules"] ) ){
                       $fname   = $fields["name"];
                       $ftype   = $fields["type"];
                       $dformat = isset( $fields["format"] ) ? $fields["format"] : "";
                       $uvalue  = $_REQUEST[$fname];
                       $p_rules = $fields["field_rules"];
                       /* Iterate through the rules and update the price */
                       foreach ( $p_rules as $prule ) {
                           if ( !wcff()->negotiator->check_rules ( $prule, $uvalue, $ftype, $dformat ) ) {
                               foreach( $prule["field_rules"] as $each_f_k => $each_f_v ){
                                   if( $each_f_v == "show" ){
                                       for( $p = 0; $p < count( $this->product_fields ); $p++ ){
                                           foreach ( $this->product_fields[$p] as $key_infield => $infield) {
                                               if( $infield["name"] == $each_f_k ){
                                                 unset( $this->product_fields[$p][$key_infield] );
                                               }
                                           }
                                       }
                                   }
                               }
                           }
                       }
                   }
               }
            }
        }
Viewing 1 replies (of 1 total)
  • The topic ‘Hidden File Upload Not Validating (Not set as required)’ is closed to new replies.