[Resolved] Create a list of members with radio buttons and save information in custom post

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.

This topic contains 1 reply, has 2 voices.

Last updated by Jamal 1 month, 1 week ago.

Assigned support staff: Jamal.

Author
Posts
#1634449

Tell us what you are trying to do?
I'm working on an management tool for swimming clubs to documet their training sessions. With the following structure:

club <many to many> members <one to many> training days <one to many> training sessions
club <many to many> groups <one to many> training days <one to many> training sessions
groups <many to many> members

In the training sessions of the members, they can document their own training attendance.
However, I also have to document the attendance for the entire group in an overview list under the training session of the group.

I need a list of the members and for every member a list of radio button options. Then I have to save this information to the group training session. How Can I do this?

Is it possible to create a list view of the members, add the radio button option list to each member and save this as generic fields to a cred form? Or do you have an other idea, how I can resolve this problem?

The Problem is that members change over time.

Is there any documentation that you are following?
No

Is there a similar example that we can see?
No

What is the link to your site?
Unfortunately not really at the moment.

#1635415

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+01:00)

Hello and thank you for contacting the Toolset support.

I am not sure to understand your data model very well, how you would save attendance and what values you will have for your radio buttons. What do you mean by the group training session? Is there a difference between it and a user training session?
But I'll try to answer your questions from what I understood so far.

If you mean to edit or add many posts with one form, Toolset does not support it. Each Toolset form is bound only to one post.
If you mean the same as in the WordPress backend, where you can select a certain amount of posts and choose "edit" in the bulk actions, no way for relationships.

But what is possible, is creating a View, that lists your posts you want to edit. Then, instead of the Post, you insert a Form, that edits the Post, in the View's Loop section. Once the View is inserted into a page, it will display a list of forms, where you can edit each post in a single action.

To bulk update or edit, it would require elaborated custom code that is out of the scope of the support forum. You can hook into the form cred_save_data action, use the relationship API to get or add related posts and use WordPress functions to create/update the related posts. You can find all the relevant documentation on the following links:
- https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data
- https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/
- https://developer.wordpress.org/reference/

Is it possible to combine views and generic fields? It may be possible. Just remember, that a generic field is bound to a form, you will have to use the view inside a form. Then you will have to hook into cred_save_data
You may also use your own shortcode to generate the list of radio buttons, or mix shortcodes, views, generic field, or native/regular fields and manipulate the posted data on your cred_save_data hook.

I hope this answers your questions. Otherwise, please provide as many details as possible, maybe drafts that will explain what you are trying to get.