Upload files to a selected directory with placeholder

ebeijes

New Member
I'd like to upload files to the server in directories called from a database-join element.

I've created several Articles in Joomla for departments at work.
for example. an article called sales, rentals and so on

In my list I created a form wit a database-join element to read the departments from the Joomla articles.
That works fine. dropdown with value and labels created.

I also created an upload element.
In the upload I want to store the uploaded file in the directory with the name(title) of that article selected.

There is a place holder {tablename___elementname}, this should give back the label of the element and should be usable for this.

But this creates a directory with the ID (value) But i need the title as directory. so it can be read by Jdownloads component.

The outcome should be: docs/sales/procedure/file.txt
but the outcome is: docs/4/procedure/file.txt (where 4 is the id of the article)

Adding _raw to placeholder gives the value and is not working
http://fabrikar.com/forums/index.php?wiki/placeholders/#raw-values
 

Attachments

  • upload_2017-3-9_22-39-32.png
    upload_2017-3-9_22-39-32.png
    14 KB · Views: 32
Yeah, that's one of those chicken and egg situations. Files are moved, during pre-processing, before element values get replaced with labels (which doesn't happen till right at the end, when we process any plugins like 'email' that may need labels). So the problem is that the "labels" on a join dropdown (an HTML 'select') don't get submitted with the form. That's not a Fabrik thing, that's an HTML thing. The posted data is just the value of the selected option. And changing that behavior in the upload element would be a lot of work.

One workaround might be to use a little custom JS, and have a hidden field (so add a field element to your form, set Hidden to yes), then add a JS 'click' event to your join element with this code:

Code:
this.form.formElements.get('yourtable___hiddenfield').update(jQuery("#yourtable___articles option:selected").html());

That should insert the label of the selected article into your hidden field whenever your select it. It may need to be a 'change' event, not 'click', I can never remember with dropdowns.

Then use {yourtable___hiddenfield} in the file path.

-- hugh
 
Hi Cheesgrits,

That almost did the trick, I added the javascript to the dropdown element where i choose the group.
event is set to 'change' on that element. than the 'hidden' field is filled with the correct data which i can use in my path

Thanks very much.
 
Back
Top