-
Notifications
You must be signed in to change notification settings - Fork 254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Restore original value of the field when upload failed. #391
Restore original value of the field when upload failed. #391
Conversation
|
||
- ``restoreValueOnFailure``: Restores original value of the current field when uploaded file has error | ||
|
||
- Defaults: (boolean) ``false`` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Defaulting to true
would make more sense imo. No one want to lose existing data :)
@Michael-Gusev can you adjust to @ADmad's suggestion? Sane defaults are great :) |
@josegonzalez @ADmad, code has been updated. |
Looks good to me, thoughts @ADmad before I merge this? |
LGTM but even with current code I don't see how your existing values would be overwritten. The @Michael-Gusev Have you actually experienced existing values being lost when editing record without uploading a file? |
@ADmad, I have simple form. echo $this->Form-input('image', ['type' => 'file']) in controller $this->Products->patchEntity($entity, $this-request->data);
$this->Products->save($entity); so when I save form without choosing file it sets value of image to null. |
I am unable to reproduce the behavior you mention. Though I do get an error
and field gets saved with value "Array", when an upload error like Personally after restoring original value I would also set the field as not dirty so as to avoid unnecessarily re-saving existing value. |
It helps to keep original value if we just have file field on form and don't want to upload it but keep original file.
@ADmad, you're right, also updated dirty. |
It helps to keep original value if we just have file field on form and don't want to upload it but keep original file.
@josegonzalez, could you review?