Skip Navigation

[Closed] Modify Repeatable Group behaviour

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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 7 replies, has 2 voices.

Last updated by Minesh 1 year, 11 months ago.

Assisted by: Minesh.

Author
Posts
#2646033

Anonymous
Toolset_Projectsamples.png
Testproject_livepreview_frontend.png
Edit_repeatable_Group_Frontend.png
Edit_Postform_repeatable_Group_Edit_Characterlist_Backend.png
Characteroverview_Backend.png

Tell us what you are trying to do?

Hey guys, I recently purchased Toolset and really love it!

I am currently trying to build a frontend solution for production managers in the field of audio postproduction.
There are "projects" that can be created by the managers only in the frontend.
I have built a project template and an editable Form that contains information about the project, technical information and deadlines. This all works wonderfully.
However, there is also a "character list" (repeatable Field Group) in which the project managers can enter characters, cue numbers, actors and their booking status. I used a repeatable field group for this and embedded it in the template via a view module.
The manager should be able to edit the individual lines and add new ones. However, in my current settings, the Production Manager always has to select the project in the Edit Form view, which is not feasible for us because there are other projects from other managers that the Production Manager is not allowed to select. Also, the Edit Form link always leads to the current project, so selecting the Project again would be a double confirmation.
The same applies to the "Add New" link. Again, the manager is forced to select the project. This makes no sense, since he is editing the current project.
In addition, after confirming via the Submit button, the user should be taken back to the previously edited project. However, this selection is not available.

For further Demonstration I added some Images.

Is there any documentation that you are following?

https://toolset.com/course-lesson/creating-and-displaying-repeatable-field-groups/

https://toolset.com/course-lesson/front-end-forms-for-editing-content/

https://toolset.com/course-lesson/front-end-forms-for-repeatable-field-groups/

Is there a similar example that we can see?

To describe the problem more clearly, I have attached some images.

What is the link to your site?

currently development Site - Localhost

#2646075

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

As I understand - you do not want to select or hide the parent post dropdown where user will have to select the parent again.

What if you hide the parent dropdown selector by adding the CSS - will that work for you?

#2646077

Anonymous

Hey Minesh,
thanks for your reply.

Unfortunately, this is not a solution for us, as users can simply display the list again via the Inspector.

Is the current project from which the user accesses the edit form selected by default?

#2646113

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Yes - there are multiple ways you can assign parent.

You can add a Generic hidden field to your form that will hold the parent post ID and later use the hook "cred_save_data" to connect the repeating field group post you edit to it's associated parent ID.

In that case you should remove the existing parent post select dropdown from your form and add a generic hidden field that will hold the parent post ID.

For example:
- Add generic field to your form and remove the existing one.

[cred_generic_field type='hidden' field='parent_post_id']
{
"default":"[wpv-search-term param='parent_id']"
}
[/cred_generic_field]

Where:
- Replace the URL param 'parent_id' with your original URL param.

- Assign the default value of your parent. Is parent ID available as URL param, if yes, then you can use the [wpv-search-term] shortcode to get the URL param value.
=> https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-search-term

Then, You can use the "cred_save_data" hook with Toolset post relationship API function
- https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_connect_posts
- https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data

For example:
- Add the following code to "Custom Code" section offered by Toolset:
=> https://toolset.com/documentation/programmer-reference/adding-custom-code/using-toolset-to-add-custom-code/

add_action('cred_save_data','func_connect_child_posts',10,2);
function func_connect_child_posts($post_id,$form_data) {
    if ($form_data['id']==999999) {
        $relationsip_slug = 'your-repeating-field-group-slug';     
        toolset_connect_posts($relationsip_slug,$_POST['parent_post_id'], $post_id);
    }
}

Where:
- Replace 999999 with your original form ID
- Replace $relationsip_slug value with your original value

#2646175

Anonymous

Hey Minesh,

thanks again for your detailed reply with a poweful Solution.

However, I have decided to hide the field via CSS:
display:none;
as it currently looks like I cannot select any other project at all.

What about the link back to the project?
Does the button support
[cred_field field='form_submit' output='bootstrap' value='Submit' class='btn btn-primary btn-lg']
a link back to the current project?

One more thing:
How does it work if I want to add a new "record" (new line to characterlist) but want the field below the loop/portal, as I don't want a link to the new character creation in every line? (See 2646033-Toolset_Projectsamples.png)

#2646179

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

What about the link back to the project?
Does the button support
[cred_field field='form_submit' output='bootstrap' value='Submit' class='btn btn-primary btn-lg']
a link back to the current project?
==>
You can use the Toolset form's hook "cred_success_redirect" to redirect user to your desired parent page. If parent page is dynamic, as shared before you can add generic hidden field that should hold parent post ID and later you can catch the parent post ID within "cred_success_redirect" using $_POST and get the URL of that parent post ID and redirect to that URL.

More info:
- https://toolset.com/documentation/programmer-reference/cred-api/#cred_success_redirect

One more thing:
How does it work if I want to add a new "record" (new line to characterlist) but want the field below the loop/portal, as I don't want a link to the new character creation in every line? (See 2646033-Toolset_Projectsamples.png)
===>
Lets say you are on "listing page" where you display all post list, then, You can create a new page for instance "create new record" and add your post form to create new post you created to this page and then add a link to this page "create new record" so when user click on this link user will be redirected to the page "create new record" where user fill the form and submit and when user submit the form from the form settings "After visitor submit the form" section you can chose the listing page where you display all records.

More info:
- https://toolset.com/course-lesson/front-end-forms-for-adding-content/

#2646243

Anonymous

For example:
- Add generic field to your form and remove the existing one.

generic_field type='hidden' field='parent_post_id']
{
"default":"[wpv-search-term param='parent_id']"
}
[/cred_generic_field]
Where:
- Replace the URL param 'parent_id' with your original URL param.

=>
how do I get the 'parent_id' ?

You can use the Toolset form's hook "cred_success_redirect" to redirect user to your desired parent page. If parent page is dynamic, as shared before you can add generic hidden field that should hold parent post ID and later you can catch the parent post ID within "cred_success_redirect" using $_POST and get the URL of that parent post ID and redirect to that URL.

More info:
- https://toolset.com/documentation/programmer-reference/cred-api/#cred_success_redirect

==>

Sorry but I cannot recreate what you are referring to. Can you maybe give me a step by step walkthrough?
Maybe I am a bit too limited in my database thinking, but in e.g. Filemaker I need a relationship between two databases to access a $Parent_ID with a $fk_Parent_ID. Currently, however, no relationship or relationship Forms are set in Toolset.

Lets say you are on "listing page" where you display all post list, then, You can create a new page for instance "create new record" and add your post form to create new post you created to this page and then add a link to this page "create new record" so when user click on this link user will be redirected to the page "create new record" where user fill the form and submit and when user submit the form from the form settings "After visitor submit the form" section you can chose the listing page where you display all records.

===>

I do not want to create a new post/project, but create a new row within the post/project for the repeatable field group "Characterlist", which is displayed via a view module within the post/project.
The problem is that the button/label text for this should not be displayed within the characterlist loop (portal that shows all "related Records of Characterlist"), but below the loop. When I try to use the button/label text as in
https://toolset.com/course-lesson/front-end-forms-for-editing-content/
the edit form is not displayed outside the loop, but inside it is. However, I don't want to have an "add new Character" button/label text in every line, but only one below or above the loop.

Sorry for the long messages and that I can't quite follow your thoughts. Maybe you overestimate my web design and toolset knowledge 😉

#2646393

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

it was just example to get 'parent_id' - you can take the name of your URL param that holds the parent ID or assign the existing value of your parent dropdown ID.

If you can share admin access details and problem URL I will be able to guide you in the right direction. If you want a sandbox site where you can replicate your functionality and your site flow then let me know I will offer you a brand new sandbox site where you can setup your requirement and then I will be able to guide you in the right direction.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

The topic ‘[Closed] Modify Repeatable Group behaviour’ is closed to new replies.