Skip Navigation

[Résolu] Cred form for repeatable group – only allow to add to current post

Ce fil est résolu. Voici une description du problème et la solution proposée.

Problem:
A form to add repeatable field groups includes a selector to specify which post they belong to. How to pre-select that post?

Solution:
Repeatable field groups are implemented as child posts of the post to which the fields belong, and the normal workflow for adding child posts where the parent is predefined is described in the linked documentation.

In this case, the client was including the forms to add repeatable field groups directly in the output of a View, in which case the parent post could be specified by using the wpv-post-id shortcode to provide the default value for the selector.

Relevant Documentation:
https://toolset.com/documentation/post-relationships/selecting-parent-posts-using-forms-create-child-items/

This support ticket is created Il y a 4 années et 8 mois. 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+01:00)

This topic contains 6 réponses, has 2 voix.

Last updated by Ido Angel Il y a 4 années et 8 mois.

Assisted by: Nigel.

Auteur
Publications
#1326801

hey,

I have an order cpt with repeatable group for notes.

I have created a cred form for creating new "notes", but the cred form only allows me to choose which post i want to add the notes to, whereas I need it to allow posting new repeatable notes ONLY FOR THE CURRENT POST.

Is there a way to make the cred form NOT display the select box for choosing a post, and only allow to use this in the current post, similar to showing only the current author?

thx!

#1326949

Nigel
Supporter

Languages: Anglais (English ) Espagnol (Español )

Timezone: Europe/London (GMT+01:00)

The repeatable field groups are implemented using child posts, so setting the post to which the repeatable field group belongs is done in the same way as pre-selecting which parent post a child post belongs to.

That's documented here: https://toolset.com/documentation/post-relationships/selecting-parent-posts-using-forms-create-child-items/

Can you look at that and apply the same technique for your form to add repeatable field groups, and if you are stuck let me know.

#1326967

Hey Nigel!

Still stuck. I think nowhere in the documentation does it say anything about "current post".
The relationship field in repeatable field form doesn't the ability to determine the current post...

My form is:

[credform]
	[cred_field field='form_messages' class='alert alert-warning']
	<div class="form-group">
		[cred_field field='sender-note' force_type='field' class='form-control' output='bootstrap']
	</div>
	<div class="form-group">
		[cred_field field='@sender-notes.parent' class='form-control' output='bootstrap' select_text='--- not set ---' author='$current']
	</div>
	[cred_field field='form_submit' output='bootstrap' value='Add Note' class='btn btn-primary btn-lg']
[/credform]

any help appreciated!
thx 🙂
ido

#1326991

Nigel
Supporter

Languages: Anglais (English ) Espagnol (Español )

Timezone: Europe/London (GMT+01:00)

Screenshot 2019-08-29 at 11.58.11.png

What is the workflow for publishing these notes?

The expected workflow is that you are viewing a parent post (or the post that the RFG will belong to) and that the template for these posts includes a link to the form to add child posts.

You can insert such a link using the Toolset Forms button and Create Child Post Link, where in the resulting dialog you specify that the parent will be the current post where the link is inserted (screenshot).

#1327029

not sure i understand.
the flow is:

i have a view with a table showing all orders (posts).
in the table, there's a td which includes the "add notes" form, which is just a cred form for creating the repeatable field.

when i try to insert a child post link into the view, i can't see the form in the choice area.

is this because it's a view and not the content template of the order?

is there a way to insert such a link into a view displaying all orders?
thx!

#1327107

Nigel
Supporter

Languages: Anglais (English ) Espagnol (Español )

Timezone: Europe/London (GMT+01:00)

OK, slightly different, as you are including the form itself (multiple times, once for every post, or row of the table).

In which case you can edit your form which will include a field for the parent selector, and you can provide the default value which should be the ID of the parent post—the current post in the loop—so insert the wpv-post-id shortcode, which will provide the ID of the current post in the loop.

Does that make better sense?

#1327321

Perfect Sense 🙂 I tried before using the post-title, but that didn't work - thx for all the help!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.