Let's start with a simplified version my code:
Model: Sku.php
class Sku extends AppModel {
}
Controller: SkusController.php
class SkusController extends AppController {
public function admin_add() {
$this->layout = 'admin';
if($this->request->is('post')) {
if($this->Sku->save($this->request->data)) {
// Do stuff
}
else // Do stuff
}
}
}
View: Skus > admin_add.ctp
<?php echo $this->Form->create('Sku', array('type'=>'file')); ?>
<?php echo $this->Form->input('Sku.item_no')); ?>
<?php echo $this->Form->input('Sku.size'); ?>
<?php echo $this->Form->input('Sku.color'); ?>
<button type="submit">Save SKU</button>
<?php echo $this->Form->end(); ?>
When I submit the form I get the error Call to a member function save() on a non-object. At the beginning of my controller file if I add the following everything works fine and a new row is inserted into the skus table.
public $uses = 'Sku';
If I have used all the proper naming conventions shouldn't I be able to omit the previous line? Furthermore, If I change all of the file and class names to Test following the same naming conventions it works without the $uses variable. This leads me to believe I have some sort of conflict elsewhere in my code. Any suggestions as to why this may be happening or where to look for a potential problem?
Thanks in advance!