[eluser]ice_prince7[/eluser]
Hi all,
sorry to bother you with this might-be-something-obvious problem
Im trying out Modular extension by wiredesignz.
I got stumble when i want to pass data via form_open.
it seems that it doesnt go to my immediate controller, but rather to index.php/product/add_to_cart.
This is my hierachy
Quote:application/
modules/
product/
controllers/product.php
views/product_list.php
This is my controller
Code:
<?php
class Product extends Controller {
function __construct()
{
parent::Controller();
}
function product_list()
{
#get products
$get_product = $this->db->get('product');
$data['product'] = 'empty';
if($get_product->num_rows()>0){
$data['product']=$get_product->result();
}
$this->load->view('product_list',$data);
}
function add_to_cart(){
echo 'asdsadas';
print_r($this->input->post('product'));
}
}
/* End of file product.php */
/* Location: ./application/modules/product/controllers/product.php */
This is my view :
Code:
<div id="cart">
<h1>Product List</h1>
<div id="content">
<?php if($product=='empty'){
?><div>There is no product yet</div><?php
}else{
?>
<table>
<tr>
<td>Item</td>
<td>Quantity</td>
<td>Price</td>
<td> </td>
</tr>
<?php
foreach($product as $item){
$len =20;
?>
<tr>
<td><?php if(strlen($item->productName)>=$len){echo substr($item->productName,0,$len).'...';}else{echo $item->productName;}; ?></td>
<td><?php echo $item->quantity; ?></td>
<td>Price</td>
<td>
<?php echo form_open('product/add_to_cart');?>// here is where im passing my data
<input type="submit" name="product[<?php echo $item->productId; ?>]" value="Add to Cart" />
<?php echo form_close();?>
</td>
</tr>
<?php
}
?></table><?php
}?>
</div>
</div>
Any ideas on how do i get the data from view to controllers/product/add_to_cart ?
sorry for posting any noob question.
thankx