• Resolved eyewebdesign

    (@eyewebdesign)


    Hi,

    Is it possible to have custom validation on dynamic fields?

    for example for custom validation on a number field I use the hook wpcf7_validate_number*, but this doesn’t work for dynamic_number. I tried wpcf7_validate_dynamic_number* but this doesn’t work…

    Kind regards
    Davy

Viewing 8 replies - 1 through 8 (of 8 total)
  • Yep, this is something I can add!

    Thread Starter eyewebdesign

    (@eyewebdesign)

    Okay, that would be great! Can you let me know when it’s done?

    Yep, will do!

    Thread Starter eyewebdesign

    (@eyewebdesign)

    awesome, thanks a lot!

    So I finally got a chance to poke around and in my own code, I do add the filter for custom validation but the priority is set to 20 and accepts two parameters. If you want your validation to take place after DTX, try a higher priority like this:

    add_filter("wpcf7_validate_dynamic_number*", 'validate_dynamic_number', 30, 2); // Default is 10, DTX priority is 20
    
    /**
     * Custom DTX Number Validation
     *
     * Frontend validation for DTX number fields
     *
     * @param WPCF7_Validation $result the current validation result object
     * @param WPCF7_FormTag $tag the current form tag being filtered for validation
     *
     * @return WPCF7_Validation a possibly modified validation result object
     */
    function validate_dynamic_number($result, $tag) {
        // Do something
    }

    Let me know if that works!

    Thread Starter eyewebdesign

    (@eyewebdesign)

    Hi,

    Okay thanks, should I update the plugin to a newer version then?

    I also need this for dynamic text if this is possible.

    Kind regards
    Davy

    No, I mean using the hook you tried earlier should work if you set the priority to be something higher than 20

    Thread Starter eyewebdesign

    (@eyewebdesign)

    That works, thanks a lot!

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Custom validation on dynamic fields’ is closed to new replies.