The form helper does not handle this functionality. The form helper
merely creates the input fields in the HTML and pre-populates it with
data set within the controller.

It should be pretty easy. When "editing", in the view just check if
the image path is set and then display it.

<?php if (!empty($data['Model']['image'])) {
echo $this->Html->image($data['Model']['image'], array('alt' => ''));
} ?>

Along side this you will also display the file upload input. Then in
the controller you just check if the file input is not empty, and if
it does, overwrite the previous image.

On Sep 20, 2:16 am, mpeshev <[email protected]> wrote:
> Hello,
>
> I'm using the form helper to generate my forms. I've added a multipart
> form with a file field which I add successfully. The problem is: how
> to edit the model with file existing?
>
> I use the standard file upload functionality from 
> here:http://www.php.net/manual/en/features.file-upload.post-method.phpand
> I save the filename in the database field. Is there a way to
> automatically view the file (name + link) when editing the entity and
> update the file only if a new file is selected?
>
> I could get the field and obtain the file in the controller and later
> check if a new file is uploaded, but I think there should be easier
> way from the form helper.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" 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

Reply via email to