Skip Navigation

[Resolved] Display a multiple instance text field as radio field in the post form

This thread is resolved. Here is a description of the problem and solution.

Problem:

Display a text field in repeatable field group as radio field in the post form.

Solution:

It needs another post view, to query repeatable field group posts, and display text field "room-internal-name", output as JSON format:

https://toolset.com/forums/topic/display-a-multiple-instance-text-field-as-radio-field-in-the-post-form/#post-1130563

Relevant Documentation:

https://toolset.com/documentation/getting-started-with-toolset/creating-and-displaying-repeatable-field-groups/#displaying-repeatable-field-groups

This support ticket is created 5 years, 6 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.

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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Hong_Kong (GMT+08:00)

This topic contains 3 replies, has 2 voices.

Last updated by domenicoS 5 years, 6 months ago.

Assisted by: Luo Yang.

Author
Posts
#1130426

Hi,

I'm trying to do the same process with another field which is not a date but a simple single line field and it is part of a repeatable group. The field slug is field "room-internal-name"

1) as you I create a custom single line field "offered-room"

2) I create this content template

[wpv-for-each field="wpcf-room-internal-name" start="1" end="1"]{"value":"[types field='room-internal-name' style='text'][/types]","label":"[types field='room-internal-name' style='text'][/types]"}[/wpv-for-each]
[wpv-for-each field="wpcf-room-internal-name" start="2"], {"value":"[types field='room-internal-name' style='text'][/types]","label":"[types field='room-internal-name' style='text'][/types]"}[/wpv-for-each]

3) Set this code in the form

          	<div class="form-group" id="select-number-field">
		<label>Room</label>
[cred_generic_field type='radio' field='wpcf-offered-room']
{
"required":0,
"default":["111"],
"persist": 1,
"options":[[wpv-post-body view_template="room-quote" id="$current" suppress_filters="true"]]
}
[/cred_generic_field]

But I'm not able to see the field and the options in the frontend form.

What could be the problem?

#1130428

Hi,

Your website isn't in English, please elaborate the questions with more details?
Where and how do you setup the custom field "room-internal-name"?
which one is the "form" you mentioned above?
Where can I test the result in front-end?

I need to test and debug it in a live website

#1130563

The information you provided are very confused , and your website structures are complicated.

Here are what I found:
1) The problem page URL is a single "Preventivo" post,
2) You are using Toolset form to edit single "Preventivo" post
3) The data source is in another post type "Accommodations", which is using one-to-many relationship with "Preventivo" post type.
4) The custom field "room-internal-name" is in a field group of "Camere" of post type "Accommodations".

So in this case, it needs another post view, to query "Camere" posts, and display field "room-internal-name", output as JSON format.

I have done below modifications in your website:
1) Create a post view "list child Camere post Room Name as JSON format"
hidden link
- query "Camere" posts,
- filter by: Select items from the Camere group that are a related to the current post in the loop.
- Enable option "Disable the wrapping DIV around the View"

In view's loop, output JSON data, like this:

...
<wpv-loop>
		[wpv-item index=1]{"value":"[types field='room-internal-name'][/types]","label":"[types field='room-internal-name'][/types]"}
		[wpv-item index=other],{"value":"[types field='room-internal-name'][/types]","label":"[types field='room-internal-name'][/types]"}
</wpv-loop>
...

Same as your previous post, output the first item without comma.
Here is a document about "Displaying Repeatable Field Groups"
https://toolset.com/documentation/getting-started-with-toolset/creating-and-displaying-repeatable-field-groups/#displaying-repeatable-field-groups

2) Edit the content template "room-quote":
hidden link
display above post view:
[wpv-view name="list-child-camere-post-room-name-as-json-format"]

3) Edit the post form "Edit Quote":
hidden link
Change the generic field shortcode to:

"options":[[wpv-post-body view_template="room-quote" item="@preventivo-struttura.parent" suppress_filters="true"]]

For the attribute item="@preventivo-struttura.parent", please check this document:
https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/#displaying-one-related-item-parent

Please check if it is what you want.

#1130669

My issue is resolved now. Thank you!

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