Let me explain what i have here. I have 2 models, Inventory & Photo.
I have defined an association that Inventory hasMany Photo. ie. a Car
can have many photos.
I have the inventoriesController set up and working properly. it
contains the basic admin_index(), admin_add(), admin_edit(), and
admin_delete() functions.
In the view for index() i have links to edit & delete which work
great. Next to that, i would like a link for manage photos, so that
someone can click on that and add more photos, edit or even delete
photos.
this is set in my inventoriesController and it works accordingly to
list the relevant photo's to the inventory it is.
function admin_photos($id) {
$conditions = array('Photo.inventory_id' => $id);
$photos = $this->Photo->findAll($conditions);
$this->set('photos',$photos);
}
and the url would appear as /admin/inventories/photos/37. now when i
want to add photos, i tried using a url of admin/inventories/photos/
addphotos/ but it keeps getting error message:
Missing Method in InventoriesController
You are seeing this error because the action admin is not defined in
controller InventoriesController
If you want to customize this error message, create app\views/errors/
missing_action.thtml.
Fatal: Confirm you have created the InventoriesController::admin() in
file : app\controllers\inventories_controller.php
<?php
class InventoriesController extends AppController {
function admin() {
}
}
?>
but there is a method that i have which is:
function admin_addphotos() {
$this->checkSession();
if (!empty($this->data)) {
if(is_uploaded_file($this->data['Photo']['img']['tmp_name']) ) {
move_uploaded_file($this->data['Photo']['img']['tmp_name'],
"../webroot/img/inv/{$this->data['Photo']['img']['name']}" );
$this->data['Photo']['img'] =
$this->data['Photo']['img']
['name'];
}
$this->Photo->save($this->data);
$this->flash("Your post has been
saved.","/admin/inventories/photos/
{$this->data['Photo']['inventory_id']}");
}
}
Here are my questions. should admin_addphotos() actually be in a
photosController? i'm kind of mixed up and lost with this process.
the association works properly where i placed some data into the db
table photos and stored the proper inventory_id foreign key in there.
but i can't seem to add more photo's through my function.
the paste is located here http://bin.cakephp.org/view/6491703 i know i
probably didn't explain things that well.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---