• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Form data preview - let user choose to submit or edit again

Hi igniters!

First post here, started today learning this beautiful framework, so let me just say as more I program with CodeIgniter more I like it.

I was working on a site with no php framework for a week, with just a few hours I've remade all site using CodeIgniter!! I'm impressed with speed of deving!

Thanks for all the develop and documentation, both are really awesome!!

Now for my first problem that required a post:

I have a controler with this function:
function AddClient(){

        $this->form_validation->set_rules('logo', 'Logo' , 'trim');
        $this->form_validation->set_rules('name', 'Nome' , 'trim|required|min_length[2]');
        $this->form_validation->set_rules('address', 'Morada' , 'trim|required|min_length[2]');
        $this->form_validation->set_rules('postalCode', 'Código Postal' , 'trim|required|exact_length[8]');
        $this->form_validation->set_rules('town_city', 'Cidade/Distrito' , 'trim|required|min_length[2]');
        $this->form_validation->set_rules('country', 'País' , 'trim|required');
        $this->form_validation->set_rules('generalContact', 'Contacto geral' , 'trim|required|numeric|exact_length[9]');
        $this->form_validation->set_rules('generalEmail', 'E-mail' , 'trim|required|valid_email');

        if ($this->form_validation->run() == FALSE){
            //Form Atributes
            $attributes = array('class' => 'addForm', 'id' => 'addClient');
            $formTag = form_open('clients/AddClient', $attributes);

            $data = array('formAction' => $formTag);

            $this->load->view('AddClient_form_view', $data);
            $data['logo'] = $this->input->get_post('logo');
            $data['name'] = $this->input->get_post('name');
            $data['address'] = $this->input->get_post('address');
            $data['postalCode'] = $this->input->get_post('postalCode');
            $data['town_city'] = $this->input->get_post('town_city');
            $data['country'] = $this->input->get_post('country');
            $data['generalContact'] = $this->input->get_post('generalContact');
            $data['generalEmail'] = $this->input->get_post('generalEmail');
            $this->load->view('AddClient_verify_view', $data);

every thing is working the problem is in AddClient_verify_view page:

<table class="verifyForm">
<tr><td>C&eacute;digo Postal:</td><td>&lt;?=$postalCode?&gt;</td></tr>
<tr><td>Contacto geral:</td><td>&lt;?=$generalContact?&gt;</td></tr>
<tr><td>E-mail geral:</td><td>&lt;?=$generalEmail?&gt;</td></tr>
<tr><td align="center" colspan="2">&lt;input type="button" value="submit" /&gt;&lt;input type="button" value="back to edit" /></td></tr>

I don't how to pass values neither for a function to submit data to mysql DB or to get back to editing form.

Can someone pointing me to the right direction, what is the best technique to accomplish this?

TIA, cheers,


[eluser]Johan André[/eluser]
If you want show the user a preview of what he entered in a form you should post it as usual, then "catch" the data into hidden inputs of a "invisible" form (use the same fieldnames as in your first form).

If the user clicks the save-button you save the data as normal.

I probably would validate the data before showing the preview and if the validation fails return to the first form and let the user correct it.

Tks Johan André,

Gonna try to put that in practice, brb with results.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.