Code Monkey home page Code Monkey logo

Comments (9)

 avatar commented on June 29, 2024

Could you elaborate the issue more?

from cakephp-media-plugin.

andybeak avatar andybeak commented on June 29, 2024

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.

from cakephp-media-plugin.

 avatar commented on June 29, 2024

could you paste the edit ctp?

from cakephp-media-plugin.

andybeak avatar andybeak commented on June 29, 2024
Form->create('Image');?>
<fieldset>
    <legend><?php echo **('Edit Image'); ?></legend>
<?php
    echo $this->Form->input('id');
    echo $this->Form->input('caption');
    echo $this->Form->input('basename');
    echo $this->Form->input('dirname');
    echo $this->Form->input('default');
    echo $this->Form->input('product_id');
?>
</fieldset>
Form->end(**('Submit'));?>

from cakephp-media-plugin.

 avatar commented on June 29, 2024

I see what the problem is.

Form->create('Image', array('type'=>'fie'));?>

and your caption (if its the image) should be set to type file as well. Hope this helps

from cakephp-media-plugin.

andybeak avatar andybeak commented on June 29, 2024

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.

from cakephp-media-plugin.

 avatar commented on June 29, 2024

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.

from cakephp-media-plugin.

ndm2 avatar ndm2 commented on June 29, 2024

This is very old, I'd say it can be closed until someone can come up with a reproducible problem.

from cakephp-media-plugin.

bmcclure avatar bmcclure commented on June 29, 2024

Good point!

from cakephp-media-plugin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.