Closed andybeak closed 11 years ago
Could you elaborate the issue more?
Thanks for helping on this.
I've installed the media manager into a Cake installation to manage product images
Table structure for table images
:
CREATE TABLE IF NOT EXISTS images
(
id
int(11) NOT NULL AUTO_INCREMENT,
caption
varchar(45) DEFAULT NULL,
basename
varchar(45) DEFAULT NULL,
dirname
varchar(45) DEFAULT NULL,
default
tinyint(1) DEFAULT NULL,
created
datetime DEFAULT NULL,
modified
datetime DEFAULT NULL,
PRIMARY KEY (id
)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;
I've baked this model and it's controller and then installed media manager.
I added a test image which worked properly - creating the record in the database and the various size images that I require (thumb, category listing, product page).
However the delete function on a record in the table fails entirely and the edit function reports success but doesn't actually update the record.
Removing the above lines from my model allows the edit and delete functions to work again - at the cost of breaking media manager.
could you paste the edit ctp?
<?php echo $this->Form->create('Image');?>
<?php echo $this->Form->end(**('Submit'));?>
I see what the problem is. <?php echo $this->Form->create('Image', array('type'=>'fie'));?>
and your caption (if its the image) should be set to type file as well. Hope this helps
Oh my word - sorry to waste your time on that - that fixed the edit.
But the delete function still fails.
public function delete($id = null) { if (!$this->request->is('post')) { throw new MethodNotAllowedException(); } $this->Image->id = $id; if (!$this->Image->exists()) { throw new NotFoundException(__('Invalid image')); }
if ($this->Image->delete()) {
$this->Session->setFlash(__('Image deleted'));
$this->redirect(array('action'=>'index'));
} else {
$this->Session->setFlash(__('Image was not deleted'));
$this->redirect(array('action' => 'index'));
}
}
This always flashes "Image was not deleted". I have debugged and checked that $id is being passed correctly.
As soon as I remove the media behaviours from the model I am able to delete the images.
By "delete" I mean "delete from database". I do have an unlink function to remove them from disk, which I've commented out until I get the database function working.
Now this is weird, from the sites I made, it CRUD should work as long as the steps are followed, it will also delete the image linked with the data as well.
Thanks for bringing it up. Let me get back to you on this.
This is very old, I'd say it can be closed until someone can come up with a reproducible problem.
Good point!
If I add the code:
//media plugin behaviors var $actsAs = array( 'Media.Transfer', 'Media.Coupler', 'Media.Generator' );
to my model then I can no longer edit or delete the records. If I remove it then the fields provided by the media manager are not populate.