[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>
<?php $data = array('quantity'=>'quantity','value' =>$value['quantity'] ); ?>
<?php echo form_input($data) ; ?>
</td>
<td>
<?php echo $value['name']; ?>
<?php $data = array('prodid'=>'prodid','value' =>$value['prodid'] ); ?>
<?php echo form_hidden($data) ; ?>
</td>
<td>
<?php $data = array('price'=>'price','value' =>$value['price'] ); ?>
<?php echo form_input($data) ; ?>
</td>
<td>
<?php $value['weight'] = " ";?>
<?php $data = array('weight'=>'weight','value' =>$value['weight'] ); ?>
<?php echo form_input($data) ; ?>
</td>
<td>
<?php echo $value['ordervalue']; ?>
<?php $data = array('ordervalue'=>'ordervalue','value' =>$value['ordervalue'] ); ?>
<?php echo form_hidden($data) ; ?>
</td>
</tr>
<?php
endforeach;
echo form_submit('submit','Finish Sale');
echo form_close(); ?>
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);