Welcome Guest, Not a member yet? Register   Sign In
How do i get the form field contents while editing (updating) entries in database ?
#1

[eluser]Pokhara[/eluser]
my controler is

Code:
function edit_lsidebar(){

        if(isset($_POST['heading'])){
        //adding text fields
        $heading = $this->input->post('heading');
        $content_text = $this->input->post('content_text');
        $url = $this->input->post('url');
        $link_text = $this->input->post('link_text');

        $this->Lside_bar_model->edit_lsidebar($heading, $content_text, $url, $link_text);

        redirect('welcome');
    }
    else $this->load->view('edit_lside_bar', $data);    
}

and model is

Code:
function edit_lsidebar($heading, $content_text, $url, $link_text){      
    $data = array(
    'heading'=>$heading,
    'content_text'=>$content_text,
    'url'=> $url,
    'link_text' => $link_text
    );

    $this->db->where('id',$this->uri->segment(3));
    $this->db->update('lsidebar', $data);

}

all i want is see the contents in the forms while editing fields. How do i do it ?
#2

[eluser]mi6crazyheart[/eluser]
Sorry, if i miss-understood u'r question. But, if u want to see the content of u'r form then u can do htis by using this input function...
Code:
echo $this->input->post('heading'); // This will show u the content of heading input field of u'r form

Similarly, u can get others input field's content by that input function where(Inside controller function or model function) ever u want.
#3

[eluser]Pokhara[/eluser]
Yes, i want to see the contents of the form in views while editing contents. So what will be my controller and views ?

when i do this in views

Code:
<input type="text" name="heading" value="<?php echo $heading?>" size="50" />

i get this

Code:
Severity: Notice

Message: Undefined variable: heading

Filename: libraries/Loader.php(673) : eval()'d code

Line Number: 8

any help would be appreceated
#4

[eluser]mi6crazyheart[/eluser]
Are u validating u'r form data in u'r controller by using CI's form validation class ? I think u might've not. You should go through this portion of validation class: http://ellislab.com/codeigniter/user-gui...latingform

If u use validation class according as it has shown in user_guide then, validation class it self send all those form fields value automatically to view if any error cause. Bcz, the error which is coming in u'r side is occurring for that reason.

My suggestion, just do accordingly as it has shown in user_guide.




Theme © iAndrew 2016 - Forum software by © MyBB