1

I am building a custom module. In my module I have a form function which basically creates the form.

When this form is submitted, I want the form to return to a specific URL.

I have added a 'RET' hidden field to the form with the correct URL, but I am unsure how to have the form actual use this. Can anyone show me what I need to add to my existing code to achieve this.

public function form() 
{
    $entry_id = $this->EE->TMPL->fetch_param('entry_id');
    if( $entry_id === FALSE ) {
        return "";
    }

    $return = $this->EE->TMPL->fetch_param('return');

    $hidden_fields = array(
        "entry_id" => $entry_id,
        "ACT" => $this->EE->functions->fetch_action_id( 'Cdwd_waiting_list', 'submit_record' ),     
        "RET" => $return   
    );

    $form_data = array(
        "id" => $this->EE->TMPL->form_id,
        "class" => $this->EE->TMPL->form_class,
        "hidden_fields" => $hidden_fields
    );

    $tagdata = $this->EE->TMPL->tagdata;

    $form = $this->EE->functions->form_declaration($form_data) . 
        $tagdata . "</form>";

    return $form;           
}

1 Answer 1

2

Inside of your submit_record method (of your Cdwd_waiting_list class), you'll need to add something like this (after you've done everything else you need to with the form submission):

ee()->functions->redirect(
    ee()->input->post('RET')
);
exit();
0

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.