Buy Now
Sign in

Save as Draft - attachments are not saved

Angie91 , July 18 2017
A
Angie91
Hi! I need your help again ^^"

When i save the form as draft, the attachments are not saved with it. So, when i get back on the draft i had to attach all the files again.
Is this a problem already observed? Or it's only mine?

The form that i've attached it's enough to find the problem?

tyvm!!
Attachments
CFV5_FormsBackup.cf5bak
(24.05 KiB)
113 Downloads/Views
GreyHead
Hi Angie,

I have not the slightest idea what this form is designed to do - are you showing the same page multiple times and allowing a file to be uploaded each time?

If you save the file names to your table (which I don't have) then you should be able to re-build links to them to attach to an email. But as there is no Email action in your form I don't know what you want to attach them to?

Bob
ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much
A
Angie91
mmmh ok, this is quite hard to explain for me in english! >.<

are you showing the same page multiple times and allowing a file to be uploaded each time?
-- > yes.

If you save the file names to your table (which I don't have) then you should be able to re-build links to them to attach to an email.
--> the file is saved on the datebase but i dont want to attach it to an email.

i need to find the code that recovers the file on the database so, when i get back on the "draft form", i see the file already attached and i dont need to attach it again.

i hope that i've explained the problem quite well ^^"

ty for you attention!!
GreyHead
HI Angie,

I still have no idea what you want to do with this form.

If you want to allow multiple files to be uploaded then you can set a single File Upload action to allow that - or you could use a repeater to add more individual actions.

You can't re-add a form to a File Upload element because you do not know what the original upload path was, if you want to make the file editable then please see this FAQ.

Bob
ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much
A
Angie91
Okey, delete all the messages that i've write before xD i'll try to explain in another way!


In the "upload files/scegli file" (see attachment) of forms, i would like that a default file appear automatically or that this file can be resume from the batabase.

So, in this way, users that start a form can be decide to 1) keep the document already loaded and dont load another or 2) load another file.

Is this possible?? tyvm!
Attachments
UPLOAD_FILE.jpg
UPLOAD_FILE.jpg
(809.45 KiB)
209 Downloads/Views
GreyHead
Hi Angie,

Yes, with a little work - please see the FAQ that I linked to.

Bob
ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much
E
enzo.orsi
Hi Bob,
basically we would like to have as default a file from our server (that the user already previously uploaded) in order to let the user proceed without uploading again the same file (or to choose to upload different one).

For example, we were tried with this, but it looks like that for security reason does not work:

<input name="cid_fronte" id="cid_fronte" class="validate['required'] form-control gcore-height-auto A" title="" style="" multiple="0" data-load-state="" data-tooltip=""
type="file"
value="https://www.website.it/images/doc/user111/test.pdf">


Any idea?
GreyHead
Hi Enzo,

You can't set the value of a File input element like that - the 'normal' value is set in the form to be a path on the user's computer. It makes no sense to add a URL on the server.

Please see the FAQ I linked to earlier - what you can do is show some info about a file that has already been uploaded and use an empty File input element to let them upload a replacement if they wish to.

Bob
ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much
E
enzo.orsi
Thanks Bob, but the field is mandatory, so the user must load something to proceed
GreyHead
Hi enzo,

Then you'd need to remove the 'required' validation if there is already a file uploaded. You can do that be using two different code blocks - one showing the existing file and the non-required file element and the other showing a required file element.

Bob
ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much
E
enzo.orsi
Good idea!
Is it possible to do in php?

I was thinking only with "custom function validation" with JS:

function conditional_required(el){
jQuery(el).addClass("validate['required']");
}


But I don't know how to give further parameter (to check if a value is blank or not).

Thank you!!
GreyHead
Hi enzo,

I don't think that JavaScript is the way to do this. When you read the form data you can see if there is an existing file or not and then use a Custom Code action to add some CSS to show/hide the corresponding elements. Something like this:
<?php
if ( !empty($form->data['file']) {
$css = "
file_required {display: none;}
file_not_required {display: block;}
";
} else {
$css = "
file_required {display: block;}
file_not_required {display: none;}
";
}
$jdoc = \JFactory::getDocument();
$jdoc->addStyleDeclaration($css);
?>

Bob
ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much
E
enzo.orsi
"GreyHead":
Hi enzo,

I don't think that JavaScript is the way to do this. When you read the form data you can see if there is an existing file or not and then use a Custom Code action to add some CSS to show/hide the corresponding elements. Something like this:


Thank you very much Bob!
Good idea.

But I need to keep only one field, and to create conditions for making it required or not.
I was thinking to write a php code condition inside "Extra params" within the upload file field, something like:

<?php
if ( empty($form->data['file']) {
echo "required=required";
}
?>


but it seems from this place, there is not taking the php variables...

Any other idea?

Thank you!!