0

I've got an issue with Solspace Freeform whereby the required field error message is being triggered if the user chooses to go the previous page without entering any information on the current page. Is there any way to bypass this?

I already have a custom extension created which uses the freeform_module_insert_begin hook and contained within is a conditional for submitting to a previous page. Is there a function, or something, that I can use here to bypass the required field?

<?php
function checkup_method( $inputs, $entry_id, $form_id, $obj ) {
    if ( ee()->extensions->last_call !== FALSE ) {
        $inputs = ee()->extensions->last_call;
    }

    if ( get_class( $obj ) == 'Freeform' ) {

        $submit = 'submit';
        if ( isset( $_POST['submit_to_previous'] ) )
            $submit = 'previous';           

        if ( $submit == 'previous' ) {

            // Custom code           

        }

    }

    return $inputs;

}
?>

Thank you.

1 Answer 1

0

I've managed to get around this by hooking into freeform_module_validate_end. The hook in my question runs after the validation so I couldn't do anything with that. It simply clears any field errors on submitting to the previous page.

function checkup_override_required( $errors, $obj ) {

    if (ee()->extensions->last_call !== FALSE) {
        $errors = ee()->extensions->last_call;
    }

    if ( isset( $_POST['submit_to_previous'] ) ) {
        // Clear errors on submit to previous
        $obj->field_errors = array(); // This needs to be an array
    }

    return $errors;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.