ZF2 - How to Save Uploaded File when Form is not Valid on Submit - file-upload

I have a form in ZF2 where, for example, a text box and a file input box are included. What about when the form is not valid because the text box, for example, is required and user leave it blank, how can I save on the form the previously uploaded file so that it will not be uploaded again and again when the form is invalid?
Regards,
Eli

As of ZF2.1 (I think), there is support for this via the post-redirect-get plugin. The relevant documentation is here:
http://zf2.readthedocs.org/en/latest/modules/zend.form.file-upload.html#file-post-redirect-get-plugin
When you cannot separate the forms, the File Post-Redirect-Get
Controller Plugin can be used to manage the file inputs and save off
valid uploads until the entire form is valid.

You could use Validation groups to validate the none-file fields separately from the file input fields:
http://framework.zend.com/manual/2.0/en/modules/zend.form.quick-start.html#validation-groups

Related

Is there a way to prefill an uploaded file to another form in cognito forms?

I have multiple forms
and I wanted the first form to be where public users can upload a file.
However when I pull the data to another form I also want their uploaded file to be pulled by the next form. how do I do that?

Sensenet upload files to a document library - fields fill

It is possible in the moment of upload a content to a document library show the fields defined (of the document library)? At the moment, the only way that the user have to fill the fields is uploading the document first and then click edit to fill the fields.
Unfortunately there is no out-of-the box solution for this scenario. I agree that this would be useful, but currently you have to create a custom solution.
You will have to create a UI that displays the upload control (you can use the built-in Sense/Net plugin) and also the form fields. In the click event of a button, you have to first start and finish the upload, retrieve the new content id and than update the metadata fields - all this in JavaScript. This way users would not see the difference, for them this would be a single operation.
(in mid-term we plan to offer a built-in control that will make this possible, but we do not have a timeline for this feature)

Generating PDF in Orbeon

We would like to generate a PDF without using the existing "PDF" button, but we would like to add our own button that gets a custom template and generates a document filled by the data in the form.
Which Orbeon API we can use for this purpose? This API will get the form id and the PDF template and will generate the document.
The API should give us the possibility to :
Map data to the PDF.
Save the PDF in a given directory.
Sdd some changes to the PDF like adding an image and save the document (this will be our custom code).
Download the PDF after process.
What you're looking for sounds very much like Orbeon Forms' PDF template feature. With Form Runner, you can add your own buttons to the form, and those buttons can have their own label and "logic". The latter is defined in a process, which is a sequence of actions. One of those actions is send(), which as its name implies, "sends" some information related to the form to a service you provide.
You can configure that action to send a PDF generated by "filling" a PDF template with the data entered by users in the form by using send(content = "pdf"). You can find more about this in the documentation for the send() action.

Moodle PHP filehandeling

My problem is that we have made an block that opens a page witha a mform on it. And we use the editor element to start the tinyMCE editor, on the page. But when we save the output, the images oploaded to the text field is only viewable to the admin (the person who uploaded it) and in the mdl_files it sets it to be a draft file. I have been through the documentation, and i might have lost the context on the new page, but im not sure.
In Moodle, files uploaded to a form (either to a filemanager element or a text editor) are stored in a temporary 'draft' area while the form is being edited.
This is so that the actual files are not changed until the form is submitted (e.g. if an admin changed the image embedded in some text, deleting the original, you do not want anyone viewing the page during the editing to see a broken image link).
When working with files embedded in a text editor in Moodle, you need to make sure you copy all existing files into the 'draft' area before you show the form, then copy the 'draft' images into the real area, after the form is submitted.
See https://docs.moodle.org/dev/Using_the_File_API_in_Moodle_forms#editor for details about how to do this.
Please also note that your plugin will also need a PLUGINTYPE_PLUGINNAME_pluginfile() function in its lib.php, in order to authenticate any file requests from the user's browser and return the file contents. See any of the core activities for examples of this (e.g. mod/data/lib.php - function data_pluginfile()).

Preload file into input type="file"

I am wondering if there is a way to have a file input field start up with a file pre-loaded in to it.
For example I have a test file on my server - 'test.txt'
When the user opens the page, I want to have test.txt already loaded in to the input field so all they have to do is fill out the text fields and hit submit
Imagine it was possible. Then you could hide the input field using css and steal any file you wanted ;-)
Apparently a large security risk and browsers prevent against performing such a task.