I have a form with several input text, textarea, checkboxes...
All works until i add an input file
Query become an INSERT instead of UPDATE
You can see in debug all the another input doesn't appears in data.person
[person] => Array
(
[pcs_file] =>
)And update becomes insert[save_person] => Array
(
[data] => Array
(
[pcs_file] =>
[created] => 2019-02-14 08:39:45
[author] => 1003587
)
[_success] => Data saved successfully
[log] => Array
(
[0] => INSERT INTO `skf0d_admincrm_prospects_map` (`pcs_file`, `created`, `author`) values ('', '2019-02-14 08:39:45', '1003587');
)
Does the table have a primary key ? if yes then what is it ?
You can force the action of the save in the action settings!
Best regards
Yes there is a primary key. The save/update works correctly until i added the input file.
I solved this issue with 2 forms, one for all and one just for the file but ...
Regards
If you want it to update an existing record and insert if there's no existing record, then
1) read data
2) In the Found event, put a save data set to update
3) In the Not Found event, put a save data set to insert.
Or try the "Insert - on duplicate key update" option instead.
It's ok, i solved the problem
Thanks healy
Would you mind sharing how you solved the problem?
My issue is a form is submitted in CF6 with option to upload a file or not. (person does not need to sign in to complete this form). When the user submits uploads a file with the CF6 form, I want to edit in CC6 as needed to an updated file for the form submitted OR I want to upload a file for those forms not submitting a file on intial CF6 form submit.
My dilemma is my setup, I am able to edit any other content field but not my CF6 input field in CC6 edit.
You insight will be appreciated. Thanks
I didn't really solved this issue. I make 2 forms : one for all and one only for upload file.
The2 forms are developped with CC6
Christophe
I have no problems with my CC6 Edit form to updating any other field except my file upload field.
I created two separte forms as suggested above; one form all regular non file fields and one specific to update file upload.
I'll try to be as clear as possible to explain my current CC6 setup to update an file upload submission under CF6.
My file update form (fields) is exactly as it appears on the CF6 form.
FUNCTIONS tab
Save Data: save_update_file
data provider: {data:model}
Write actin: auto detect (I've tried Update but no luck)
data override on insert: blank
Data overide on Update: file_upload:{data:file_upload}
Update condition: aid:{data:model_aid}
VIEWS Tab
I created a form
Event: save_photo
Form name: photo_update_form
Action URL: Blank
Content: {view:photo_fields}
I created fields
Field: hidden field for my key value (aid)
Field: File -->under name:model[field}
Button: Submit --> name: save_photo
EVENTS Tab
edit_photo -->
{fn:read_single_record}
{fn:check_record_exists}
{view: photo_update_form}
save_photo -->
{fn:save_photo_update}
{fn:check_photo_save}
{redirect:index}
I just can't figure out where I am going wrong. Existing file will not update or a new file will not appear of initial cf6 submission to upload was left blank.
Again, my form for editing all my other fields made in CF6 is updating correctly. But my file upload field is not making any changes, whether there was an initial file or not under the initial CF6 submission.
[br]Hope a clear explanation can be provided for a non-programmer. Thanks
Put a {debug:} in as the last action in the event to see what data you have available. I suspect your model_aid might be empty. Additionally, your Save Data should be storing the filename returned by the FILE UPLOAD action, NOT the file field, because the filename given to the file on your server might very well be different to the filename of the file from the user's computer.
Yes, the uploaded file when another file was upload adds the date in file name...
Here's the result. Sometimes I want to have some records have the same filler image.
Put a {debug:} in as the last action in the event to see what data you have available.
pkey_name:{data:pkey_form_field_name}
table_file_field_name:{data:form_file_field_name}You may also set the action to "Update" and provide the primary key value in the "Conditions" box!
Best regards
