Problems, need help? Have a tip or advice? Post it here.
3 posts Page 1 of 1
Hello KK,
I realized something today in a data-bound form implementation. I realized you can't simple override an existing secure_file without first deleting the existing one.
I tried this, but the upload button is missing and only the delete button shows:
Code: Select all
<cms:input type="bound" name="business_logo" />


I also tried this. It work's fine except when you submit the form after changing other form fields data apart from the secure_file, the secure_file becomes empty:
Code: Select all
 <cms:hide>
<cms:input type="bound" name="business_logo" />
</cms:hide>
<input type="file" name="f_business_logo" />


1. Is there a way to override the secure_file without first deleting the existing one.
2. Prevent the secure_file from getting emptied after I update any other form field without updating the secure_file field.

Thank you
I was able to get the secure_file overriding to work in my Next Js app. What I did was:

1. First fetch all the hidden input fields from the url where the form that contains the secure_file data-bound input exists. Doing this will fetch extra input hidden fields including hidden fields from the existing secure_file but these are not needed, so I Javascript includes to excludes those fields and just grab the "k_hid_kformname0" and "k_nonce", which are what is crucial in this case.

2. Once I was able to get them, I added them to the rest of the formData and voila it works.
Code: Select all
hiddenFields.forEach(({ name, value }) => {
        formData.append(name, value); //Append the hidden fields to the existing formdata and send all voa the request body.
});



The problem now is how to do this in Couch CMS.

I went ahead of myself. Unfortunately it didn't as I thought it would
Hi,

Would it be possible for you to create a test case for me - a template with only the relevant fields and front-end code for the form displaying the problem you mentioned. Basically something that I can install on my system and see the problem for my self.

Thanks.
3 posts Page 1 of 1