On 26 Oct 2006, at 15:56, Lars Trieloff wrote:
The usecase is that a user may add a number of file-upload controls to a repeater, select files for them, then submit them all in one go.One problem is, that if you have file-upload controls on a form, that have a file selected, they get submitted when you click on the repeater's add button, as these action-events submit the whole form.This applies only to non-AJAX forms, I suppose.No, this happens with Ajax-enabled formsBut in this case the repeater's add-button should only do an ajax- request and add the new contents behind the already existing repeater-rows. So I think the main problem is making the repeater AJAX-aware.
Repeaters are already Ajax-aware.When you click to add a new row, the whole form is submitted, with the repeater's action button id in the hidden 'forms_submit_id' field. AFAICS, currently all form data is sent, but is not validated on the server.
Turning on Ajax in the form results in the whole form being submitted via Ajax techniques, a new hidden field 'cocoon-ajax=true' is created, this is detected by the response pipeline to filter and wrap any changes in the BrowserUpdate schema, which is used to inject those changes into the form.
This is how it already works.The trouble for my usecase though is that all the form fields are submitted, when not all of it is 'needed' for the event to work properly on the server.
I am trying to work out if it is safe to somehow filter out a bunch of fields from this type of submit. Only sending enough data for the action to work.
I would like to change this behaviour but do not know if this will break some other usecases.Why do you want to change the behaviour? I think it is the common behaviour in all non-ajax-enabled upload forms, so I don't see the need. In your case you would, prior to uploading get the file names from all upload fields in the repeater that already have a value, store it in a hidden field, clear the original upload field, send it to the server and when the server responds, you will copy the file names from the hidden fields to the upload fields, right? What happens if JS is deactivated?Tricks like this are not possible (if I understood you right) there is no API for setting the value of file-upload controls via javascript. It is locked down as a security issue.Ok. I didn't know this
It makes things much more complicated ;)But is very necessary .... otherwise you could programically copy any file off a user's computer =:-O
regards Jeremy
smime.p7s
Description: S/MIME cryptographic signature
