Codeigniter Form Validation - how to unset form values after success?

前端 未结 8 743
天涯浪人
天涯浪人 2020-12-23 20:36

I realise this request goes against the example provided in the CI documentation (which advises a separate \'success\' page view), but I would like to reutilise a given form

8条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-23 21:35

    Pass a TRUE/FALSE variable to your views that conditionally sets the values of the form.

    The Controller

    if($this->form_validation->run())
    {
        $data['reset'] = TRUE;
    }
    else
    {
        $data['reset'] = FALSE:
    }
    
    $this->load->view("form", $data);
    

    The View:

    " />
    
    " />
    

提交回复
热议问题