Welcome Guest, Not a member yet? Register   Sign In
Binding Model to View
#1

[eluser]clowngoblin[/eluser]
Hello,

first i am new for php programing. i read documents and searched on google but didnt find it.

i have a model Brand(record_id,name) and listing object on view with form no problem.

Controller :
Code:
function update($recordId){
        $brand = Prt_Brand::find($recordId);
        $data['brand'] = $brand;
        $data['page']='prt_brand_form';
        $this->load->view('index_view',$data);
    }

View
Code:
<body>
<?php $attributes = array('name' => 'brand');
echo form_open('prt_brand_controller/save',$attributes);?>
<table>
    <thead>
        <tr>
            <th>Id</th>
            <th>Name</th>
            <th></th>
            <th></th>
       </tr>
    </thead>
    <tr>
        <td>Name</td>
        <td>&lt;?php echo form_hidden('record_id',$brand->record_id);?&gt;
            
        &lt;input type="text" name="name" id=&lt;?=$brand-&gt;record_id?&gt; value=&lt;?php echo $brand->name?&gt; maxlength="100" size="50" style="width:50%" /></td>
    </tr>
    <tr>
        <td>&lt;input type="submit" name="mysubmit" value="Submit Post!" /&gt;&lt;/td>
    </tr>
</table>
&lt;/body&gt;

Controller Save:
Code:
$brand = $this->input->post('brand'); //HERE CANT GET MODEL!
     $brand->record_id;// DONT WORK!

can i bind form(name is brand in view) to model in controller or must i get atributes one by one?


thnks for your replies.
#2

[eluser]clowngoblin[/eluser]
is it possible binding form to model?
#3

[eluser]clowngoblin[/eluser]
in java framework like struts you can bind form(with id atribute) to model in controller.


with codeigniter can i do that? plz help me yes or no. i couldnt find any tutorial or code pieces about this
#4

[eluser]ramm[/eluser]
You need to get the vars one by one. CodeIgniter doesn't have a forms class like symfony.
#5

[eluser]clowngoblin[/eluser]
Sad thanks for your answer




Theme © iAndrew 2016 - Forum software by © MyBB