简体   繁体   English

提交后再次显示表单

[英]Display form again after submit

I am trying to display a form multiple times in codeigniter. 我试图在codeigniter中多次显示一个表单。 My goal is to have a user fill a form about themselves, and then proceed to another page to input information about family members. 我的目标是让用户填写关于他们自己的表单,然后进入另一个页面以输入有关家庭成员的信息。 The number of family members will be specified in the 1st form. 家庭成员的数量将在第一种形式中指定。 i did the following, but all instances of the form are appearing on the same page, with multiple submit buttons. 我做了以下,但表单的所有实例都出现在同一页面上,有多个提交按钮。

Here is the controller function 这是控制器功能

public function register_relation_famille(){
   for ($i=1; $i<=3; $i++){
        //validation rules

             if($this->form_validation->run() == FALSE){
                $data['main_view'] = 'users/relation3/famille';
                $this->load->view('layouts/main', $data);
            } else { 
                if($this->user_model->create_relation_famille()){
                    $this->session->set_userdata('filled', 'Filled');
                    $data['main_view'] = 'home_view';
                    $this->load->view('layouts/main', $data);
                } else {
                    $this->session->set_flashdata('user_not_registered', 'User has not been registred');
                    redirect('home/index');
                }
            }
        }
    }

My Model 我的模特

public function create_relation_famille(){  
    $data = array(

        'demande_id'        =>$this->session->userdata('user_id'),
        'nom'               =>$this->input->post('nom'),
        'prenom'            =>$this->input->post('prenom'),
        'fonction'  =>$this->input->post('fonction_groupe'),
        'relation'          =>$this->input->post('relation'),
        'membre_groupe'     =>$this->input->post('membre_group'),
        'annee_service'     =>$this->input->post('annee_service')
    );

        $insert_data = $this->db->insert('relations1', $data);

        return $insert_data;

}

And i have my form which contains 5 fields and a submit button. 我的表单包含5个字段和一个提交按钮。
Can anyone help ? 有人可以帮忙吗?
Thanks 谢谢

Use jQuery to load different forms on a page. 使用jQuery在页面上加载不同的表单。 JQuery can be used to hide/show html elements. JQuery可用于隐藏/显示html元素。

$("#Form1").show(); $("#Form2").hide();

It's simpler if you use Jquery. 如果你使用Jquery,它会更简单。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM