Skip Navigation

[Resuelto] Cred form for repeatable group – only allow to add to current post

Este hilo está resuelto. Aquí tiene una descripción del problema y la solución.

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 hace 5 años, 3 meses. 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.

Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.

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+00:00)

Este tema contiene 6 respuestas, tiene 2 mensajes.

Última actualización por Ido Angel hace 5 años, 3 meses.

Asistido por: Nigel.

Autor
Mensajes
#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

Idiomas: Inglés (English ) Español (Español )

Zona horaria: Europe/London (GMT+00: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

Idiomas: Inglés (English ) Español (Español )

Zona horaria: Europe/London (GMT+00: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

Idiomas: Inglés (English ) Español (Español )

Zona horaria: Europe/London (GMT+00: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!