Welcome Guest, Not a member yet? Register   Sign In
Why will my form not update ?
#1

[eluser]vincej[/eluser]
Hi - I have used form helper succesfully in the past. Howeever this time I can't make it work.

Ok this time I am trying to firstly populate my form with existing values from a DB using a foreach.

Then the user can change the values if needed.

Then 'submit' sends them off to the controller and Model.

The controller and model are being called BUT I keep getting the same error from the model:

"undefined index" which tells me the form values are not being sent over to the model.

I think, somehow the 'foreach' syntax is wrong in the context of using a form. I mut be screwing up the sytax - but I can't see it .

Can anyone help me here

Many Many Thanks !


Here is the code, abreviated for clarity.

Form ( VIew) :

Code:
<?php foreach ($openorders as $key=>$value): ?>

<?php echo form_open('admin/pos/sales_update');?>

<tr>

    <td>
    &lt;?php $data = array('quantity'=>'quantity','value' =>$value['quantity'] );  ?&gt;
    &lt;?php echo form_input($data) ; ?&gt;
    </td>

<td>
    &lt;?php echo $value['name']; ?&gt;
    &lt;?php $data = array('prodid'=>'prodid','value' =>$value['prodid'] );  ?&gt;
    &lt;?php echo form_hidden($data) ; ?&gt;
    </td>

    <td>
    &lt;?php $data = array('price'=>'price','value' =>$value['price'] );  ?&gt;
    &lt;?php echo form_input($data) ; ?&gt;
    </td>
    
    
    <td>
    &lt;?php $value['weight'] = " ";?&gt;
    &lt;?php $data = array('weight'=>'weight','value' =>$value['weight'] );  ?&gt;
    &lt;?php echo form_input($data) ; ?&gt;
    </td>
    
    <td>
    &lt;?php echo $value['ordervalue']; ?&gt;
    &lt;?php $data = array('ordervalue'=>'ordervalue','value' =>$value['ordervalue'] );  ?&gt;
    &lt;?php echo form_hidden($data) ; ?&gt;
    </td>
</tr>
    

&lt;?php
        endforeach;
        echo form_submit('submit','Finish Sale');
        echo form_close(); ?&gt;

Controller

Code:
function open_orders($customerid){
$data['openorders'] = $this->MPos->open_orders($customerid);
$data['main'] = 'pos';
$data['title'] = "My Site | Open Orders";
$this->load->vars($data);
$this->load->view('dashboard')
;}


Model

Code:
function sales_update($customerid){
  $data = array(
                 'prodid' => db_clean($_POST['prodid']),
   'price' => db_clean($_POST['price']),
   'quantity' => db_clean($_POST['quantity']),
   'weight' => db_clean($_POST['weight']),
   'ordervalue'  => $this->input->post('ordervalue'),
    );
   $this->db->where('customerid', $customerid);
   $this->db->insert('salesupdate',$data);




Theme © iAndrew 2016 - Forum software by © MyBB