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.