0

I have a form with a number of pages and radio buttons, each one has a score attached. If the score is lower than 5 by the 5th page I need to end the form and display the results, else carry on with the rest of the questions.

I've managed to hook into the form with freeform_module_insert_begin and inject a bit of code at the correct point but I'm not sure how to 'finish' the multi-page form. The below code fires at the correct point.

//$step variable grabs the page number from the URL
if ( $step == 5 AND $inputs['total'] < 5 ) {
    //End form
    $obj->last_page = true;
}

I tried adding the $obj->last_page = true; line to trick the form into thinking it's at the end but unfortunately it didn't work and carried onto the next page.

I also tried playing with $obj->params['multipage_next_page']; and $obj->params['multipage_previous_page'] however if I unset the next_page (or direct it elsewhere) I'm getting taken to the home page.

In my freeform_module_insert_end hook:

I've tried using ee()->functions->redirect($return); where $return equals the result URL but it doesn't appear to submit properly.

1 Answer 1

0

I've finally found a solution for this. In my case it works well however it might not be viable for others. (see last sentence)

All that was needed was to set the multipage_next_page value to the landing page URL

$obj->last_page = 1; //Not sure if needed
$obj->params['multipage_next_page'] = $return_url;

This then directs the user to the result page should they meet the specification outlined in the question.

The only issue with this is that the form is left incomplete. This is fine for what I need but worth noting for anyone else.

Your Answer

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

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