Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>i had the same issue, my solution it's not really good but it worked for me, what i did is, to allowEmpty => true. and in the edit function on controller, i passed the data of that image, to the $this->data array, something like this, so when you go to the form, you already have the field 'image' with some data, and you don't have to upload the image again, or modify it.</p> <p>If it's not clear, just tell me and i'll try to break it down.</p> <p>I hope it works for you</p> <pre><code>function admin_edit($id = null) { if (!$id &amp;&amp; empty($this-&gt;data)) { $this-&gt;Session-&gt;setFlash(__('Invalid category', true)); $this-&gt;redirect(array('action' =&gt; 'index')); } if (!empty($this-&gt;data)) { if(!empty($this-&gt;data['Category']['image']['name'])) { $image_name = $this-&gt;Picture-&gt;upload_image_and_thumbnail($this-&gt;data,"image",570,70,"categories",true,"Category"); $this-&gt;data['Category']['image'] = $image_name; } else{ $image_name = $this-&gt;Category-&gt;find('first',array( 'conditions'=&gt; array( 'Category.id' =&gt; $this-&gt;data['Category']['id'] ), 'fields' =&gt; array( 'Category.image' ) )); $this-&gt;data['Category']['image'] = $image_name['Category']['image']; } if ($this-&gt;Category-&gt;save($this-&gt;data)) { $this-&gt;Session-&gt;setFlash(__('The category has been saved', true)); $this-&gt;redirect(array('action' =&gt; 'index')); } else { $this-&gt;Session-&gt;setFlash(__('The category could not be saved. Please, try again.', true)); } } if (empty($this-&gt;data)) { $this-&gt;data = $this-&gt;Category-&gt;read(null, $id); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload