1

I have a large multipage form on my site which is positioned in the middle of the page. After every page submission the page reloads which means the user has to scroll back down to proceed with the form.

I've been trying to add an anchor into the paging_url attribute so that it automatically focuses on the form after the page reloads but it only appears to be working on the first page. Once I navigate past the first page the anchor is stripped from the URL on all subsequent pages.

paging_url="/{segment_1}/{segment_2}/%page%#screening-form"

Is there a way to get this to work using an anchor? Failing that ajax could be an option and instead of loading a new page it simply pulls in the next question into the page without the browser reloading?

I currently have a less than ideal solution using javascript, the problem being there is a brief moment where the form isn't in view on page load and the jump down to it is noticeable.

function moveWindow () {
    window.location.hash="screening-form";
}

1 Answer 1

1

I've managed to fix this using an extension I had created. It hooks into freeform_module_insert_begin which allows me to modify any of the data. With this I've been able to modify the next and previous params

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' ) {

        // Other stuff

        // Append anchor to these two bits
        if ( isset( $obj->params['multipage_previous_page'] ) ) {
            $obj->params['multipage_previous_page'] .= '#screening-form';
        }
        if ( isset( $obj->params['multipage_next_page'] ) ) {
            $obj->params['multipage_next_page'] .= '#screening-form';
        }

    }

}

UPDATE

I found out that this was causing errors on completion of the form so I've wrapped the $obj->params['multipage_previous_page'] .= '#screening-form'; bits in conditionals to ensure that they exist before appending anything to them.

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.