Hi,
I tested like crazy with unset within PHP or disabling the fileupload fields in edit mode but nothing works.
In debugger window it shows always in array data [2] the empty fileuploads and on save the previously stored with the create of the dataset get deleted (empty) then.
How can I achieve this in CF7. No tip of the other versions for that worked for me!
Thank you in advance!
Best regards
IWOXX
Hi Iwoxx,
I suggest that you try using custom code or a Switch event. If the file upload is empty then you need to remove/unset that entry from the form data so that the empty value is not saved.
Bob
Hi Bob,
thank you for the quick reply. The problem is that I don't get "unset" to work even from your samples of older version and also tried some other things in PHP as well!
All tests and codings don't remove the field from the page source as I detected. And this seems to be the problem. As soon as I remove the file upload field from the form it worked and didn't overwrite the existing database value.
The idea to set the file upload field to disable that even works for most fields not to send any data to the server didn't work here!
So my current solution that I found yesterday:
I put the field into a container with a run condition. Now I can control whether it is now existing on the page or not.
1. So in the case of a new order the run condition is now displaying the file upload to do the 1st upload for this dataset.
2. In case of editing or viewing an order the run condition fails and the file upload field isn't on the form or in the page source any longer. So the existing value in the database doesn't get overwritten now because the data array value for this field disappeared then. With a Custom HTML like the following I can display the filename with a link to click and open it directly:
<a href="{l:_URL_FILE_UPLOAD_}{var:read_order.0.Model_Order.fileupload1}">{var:read_order.0.Model_Order.fileupload1}</a>
_URL_FILE_UPLOAD_ is my given absolute root path that I setup in the language section and is also set in the form settings for the standard upload path.
That is what I need for this project!
But maybe there is a more elegant solution I am not aware of at the moment?!
Kind regards
IWOXX
Hi Iwoxx,
That sounds good to me - I'm not familiar enough with CFv7 to suggest an alternative.
Bob