I am having troubles passing data from the controller to the model in opencart(1.5.3). I have modified the 'add products' form to include a file input field, however, the results I am experiencing, I don't understand, so I'd appreciate any input, or suggestions as to a solution.
When I post the form, the data is sent to the controller, but the controller does not pass it to the model, which stops the final database query from being executed.
Im not sure if this is part of this issue, but in firebug, the post data is defined in the source list, but the field name is not defined in the parts list.
Below is an example of the code. It might be worth mentioning that I am using VQmod to add changes on the fly.
View:
<table class="form">
<tr>
<td><?php echo $entry_product_pins; ?></td>
<td><input type="file" name="product_pins" /><?php echo $tab_pins_instructions; ?>
</td>
</tr>
</table>
Controller:
if (isset($this->request->files['product_pins']['tmp_name'])) {
$this->data['product_pins'] = file_get_contents($this->request->files['product_pins']['tmp_name']);
} else {
$this->data['product_pins'] = '';
}
Model:
if ( isset($this->data['product_pins']) ) {
foreach (explode(";
", $this->data['product_pins']) as $pin) {
$this->db->query("INSERT INTO " . DB_PREFIX . "product_pins SET pin_product_id = '" . (int)$product_id . "', pin_pin_number = '" . $this->db->escape($pin) . "'");
}
} else {
// added for debugging
exit("product_pins not set"); }