Welcome Guest, Not a member yet? Register   Sign In
Reloading view form with data which was passed by controller view form, not form validation fields
#1

[eluser]OneCorea[/eluser]
Suppose this!...
board controller(board/bRead) loads a read view transferring with data[] fields..
and in the read view..there's a form section in the middle of read view file,
When the form submitted, it's called the controller&method;(board/commentPost) and reloading the same view file('read' view file)


Well, here's my problem!!!..

when the 'read' view file reloaded after the form submitted..
the data[] fields is disappeared because I didn't load the data[] field inside commentPost function...

You may ask "Why don't you define every data[] fields in the function..??",
but there's lots of data[] field to define..

So,
Is there any method for 'commentPost() function' to receive every data[] field in the read view file loaded by the controller(board/bRead)?


<controllers/board.php>
Code:
class Board extends Controller{
...
...
   function bRead(){
   ....
   $data['aaa'] = 'this is aaaa data in read view';
   $data['bbb'] = 'bbb';
   ==> There's lots of $data[] fields..

   $this->load->view('read', $data);
   }

   function commentPost(){
    ...
    if($this->validation->run()){
       //==> inserting database..

       $this->load->view('read');
    }
    else{
       error msg;;;
       $this->load->view('read');
    }

   }

}

View/read.php
Code:
&lt;html&gt;&lt;body&gt;
&lt;?=$aaa?&gt;
..blah blah
&lt;?=$bbb?&gt;
...blah blah
there are lots of data field from controller
...
&lt;?=form_open('board/commentPost/$code/$no')?&gt;
   &lt;input type=text name='writer&gt;
   &lt;textarea name=comment&gt;&lt;/textarea&gt;
   &lt;input type=submit value='Submit'&gt;
&lt;/form
</body&gt;&lt;/html&gt;
#2

[eluser]OneCorea[/eluser]
Wait..i...n......g.....!!
#3

[eluser]Michael Wales[/eluser]
Just redirect to the bRead function after your db insert.
#4

[eluser]OneCorea[/eluser]
What a simple!!!, just redirecting keep the previous data[] fields!!,,,
I was only thinking silly load->view()!!,


Thanks walesmd... for hitting my head!




Theme © iAndrew 2016 - Forum software by © MyBB