Save as Draft - attachments are not saved

Angie91 18 Jul, 2017
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!!
GreyHead 18 Jul, 2017
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
Angie91 20 Jul, 2017
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 21 Jul, 2017
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
Angie91 24 Jul, 2017
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!
GreyHead 24 Jul, 2017
Hi Angie,

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

Bob
enzo.orsi 28 Jul, 2017
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 28 Jul, 2017
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
enzo.orsi 28 Jul, 2017
Thanks Bob, but the field is mandatory, so the user must load something to proceed😟
GreyHead 28 Jul, 2017
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
enzo.orsi 28 Jul, 2017
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 29 Jul, 2017
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
enzo.orsi 03 Aug, 2017

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!!
This topic is locked and no more replies can be posted.