0

That was a bug of the component being used.

I have to use multiple forms in a page.

My Problem: I can not stop the code check the unsubmitted form with the other ?automaticly?. *Errors are different. One’s error is not shown under other’s error list.

Here is my code to generate required forms using formgenlib under my controller. By the way, If I click on the first button, "//do the stuff..." doesn’t work. But errors are shown.

$this->load->library('form');
                $login_form = new $this->form;
                $login_form
                    ->open()
                    ->col(240, 'left', 'left')
                    ->text()
                    ->col(170, 'left', 'left')
                    ->password()
                    ->col(100, 'left', 'right')
                    ->submit('', 'submit_login')
                    ->col(0)
                    ->validate();
                $data['login_form'] = $login_form->get();
                $this->load->view('overal_header', $data);
                $login_form->clear();
                $radio = array(
                    array('', ''),
                    array('', ''),
                );
                $register_form = new $this->form;
                $register_form
                    ->open()
                    ->fieldset()
                    ->text()
                    ->text()
                    .
                    .
                    .
                    ->submit('', 'submit_form');
                    if($this->input->post('submit_form'))
                    {
                        $register_form->validate();
                        if($register_form->valid)
                        {
                            //do the stuff here...
                        }
                    }
                $data['form'] = $register_form->get();
                $data['errors'] = $register_form->errors;
                $register_form->clear();
                $this->load->view('page_welcome', $data);
                $this->load->view('overal_footer'); 
4

1 回答 1

0

不确定这是否重要,但文档显示使用多种形式略有不同。每个表格使用:

$this->form->text

代替

$login_form->text

并且不区分这两种形式,直到

$this->form->get()

所以清除的调用将是

$this->form->clear()

同样,不确定这是否真的重要。也许只是别的东西要看。

于 2012-05-15T00:00:52.500 回答