Skip Navigation

[Resolved] Creating a form to upload new/edit files & list of existing files to download.

This support ticket is created 4 years, 9 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Author
Posts
#1473833
firefox_2020-01-22_19-16-13.png

I'm going round in circles, just wondering how best to tackle this.

Ideally what I want is a view with a list of documents already uploaded that the user could click and download (this I've done).
Underneath this view the ability to add new documents to the list (if they have the rights).

The only fields would be a file date field and a file field (linked together).

Then also an edit option for each previously uploaded document (again if they had the rights), if that file needed to be updated.

I don't need to be stepped through each process... just what should the outline steps be.

So far I've added a Post Type with two repeating fields (I don't seem to be able to edit these on the front end?) Maybe I should be looking at repeatable groups?

Then added a view for the new CPT, no filters as of yet... using the two fields above.

Added the View to the Content Template, with the Add New form below it.

But on the front end, the view displays but I can't add (all the buttons are there but I can't click in to any of the fields and the Add button does nothing).

Once I've mastered this then I can go on to add Edit - I was thinking I'd need to follow these instructions for that.

https://toolset.com/documentation/getting-started-with-toolset/publish-content-from-the-front-end/forms-for-editing/

I think then I'd have to look at rights, so only certain users would have the right to add and edit existing documents from the front end - but again think this is dooable.

Many thanks for any pointers.

#1475089

Two repeating fields probably won't be enough here, because each date/file pair will not be linked in any meaningful way other than the order of the fields. Furthermore, it's not possible to edit individual instances of a repeating field...the front-end User would edit all instances of a field at once in a single Form, which probably isn't ideal here.

Repeatable field groups would probably be more useful, since each pair of date/file will be linked meaningfully in one RFG and you have the ability to edit each pair of fields individually in a single Form. The RFG would have to be associated with some parent post, not a User profile per se. Once you set up that post type and add the RFG in the custom field editor, you would create a View of RFG filtered by post relationship / RFG owner, set by the post where the View is shown, and place this View in the parent post type template. This will display the list of all the existing related RFGs for the post where the View is shown.

You can include a new RFG Form in the parent post template. In the Form builder, you can use expert mode to hide the parent post select field with CSS, and you can use the wpv-post-id shortcode and the $current_page operator to pre-define the parent post ID value, like this:

<div style="display:none;">
[cred_field field='@relationship-slug.parent' class='form-control' output='bootstrap' select_text='--- not set ---' value='[wpv-post-id item="$current_page"]']
</div>

This will automatically set the parent post for the RFG when the new RFG is created. I can share a KB snippet with some custom code that will reload the current page when the Form is submitted, so that the new item will appear in the View of RFG: https://kb.onthegosystems.com/code-snippet/refresh-the-page-after-submitting-a-form/

The standard edit process for RFGs is to place an "Edit post" link in the View of RFGs, which will link to a Content Template (or Layout) containing the Edit Post Form for this RFG instance. This will allow your front-end Users to edit a single pair of date/file fields. You can use the Forms redirection API to redirect back to the parent post when the Edit RFG Form is submitted, and the updated content will be displayed in the View of RFG. Here's a KB snippet: https://kb.onthegosystems.com/code-snippet/redirect-to-parent-post-after-editing-repeatable-field-group-rfg-in-forms/

Let me know if this makes sense or if you need more direct guidance.

#1475439
firefox_2020-01-23_20-07-11.png
firefox_2020-01-23_20-00-43.png

Many thanks, I've got to the point of 'You can include a new RFG Form in the parent post template.'

I stopped hiding the parent post select field just to see what was happening.

Two things, one I can't seem to type in a date. And secondly although the post is saved, I'm not sure where. I'd expect to be able to see the other posts in the unhidden 'not set' dropdown? Or actually with your code added just the parent post, but I can only see --- not set ---. I guess I've missed a relationship somewhere?

Definitely my field group is attached to the right Post Type though?

#1475533

If you can't choose a date and the parent post select field doesn't allow you to choose a parent post, that indicates a JavaScript error of some kind is blocking the Form from being fully initialized. Can I see this in the browser? Private reply fields are attached here so you can share a login.

#1475619

Forms scripts shouldn't be minified or concatenated by plugins like Autoptimize. I made some adjustments to the settings for minification and it seems to be working more like I'd expect now. Can you check?

#1475621

Ahhh, yes of course. Working as expected now. I'm going to continue with your outline tomorrow and finish off then as it's getting late now. Thank you so much for all your help. Best wishes, Lins

#1475625

Sure, I'm off tomorrow but I'll return Sunday. If you need assistance before then, feel free to create another ticket and link to this one for reference.

#1478319

My issue is resolved now. Thank you!