Skip Navigation

[Resolved] Can't get nested repeatable groups to display properly

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

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/Karachi (GMT+05:00)

This topic contains 9 replies, has 2 voices.

Last updated by ericE-4 5 years, 5 months ago.

Assisted by: Waqar.

Author
Posts
#1309331
Screenshot 2019-08-05 01.13.03.png

I am trying to: show a table containing all values from a repeatable group's first field (species name) in column 1, and all values from a nested repeatable group (containing checkboxes) to show in the second column for each row (I will format them as a flex box). For each value in the nested group, I want to render <div class="month on"></div> if the field is checked, and <div class="month off"></div> if not checked.

I have tried using the loop editor as well as coding manually based on what I've found in the support forum. Nothing works. It's honestly not very easy.

My Post Field Group looks like [image1].

View called "Fish Species List":

Loop:

[wpv-layout-start]
	[wpv-items-found]
	<!-- wpv-loop-start -->
	<table width="100%">
		<tbody class="wpv-loop js-wpv-loop">
          <wpv-loop>
			<tr>
				[wpv-post-body view_template="loop-item-in-fish-species-list"]
			</tr>
		</wpv-loop>
		</tbody>
	</table>
	<!-- wpv-loop-end -->
	[/wpv-items-found]
	[wpv-no-items-found]
		<strong>[wpml-string context="wpv-views"]No items found[/wpml-string]</strong>
	[/wpv-no-items-found]
[wpv-layout-end]

Loop item in Fish Species List:

<td>[types field="species"][/types]</td>
<td>[wpv-view name="species-availability-calendar-row"]</td>

View called "Species Availability Calendar (row)":

Loop:

[wpv-layout-start]
	[wpv-items-found]
	<!-- wpv-loop-start -->
		<wpv-loop>
				[wpv-conditional if="( $(wpcf-species-availability) = '1' )"]<div class="month on"></div>[/wpv-conditional]
				[wpv-conditional if="( empty($(wpcf-species-availability)) )"]<div class="month off"></div>[/wpv-conditional]
		</wpv-loop>
	<!-- wpv-loop-end -->
	[/wpv-items-found]
	[wpv-no-items-found]
		<strong>[wpml-string context="wpv-views"]No items found[/wpml-string]</strong>
	[/wpv-no-items-found]
[wpv-layout-end]

In the post I've embedded the "Fish Species List" view.

Link to a page where the issue can be seen:

hidden link (scroll down and click on Species Availability Calendar)

I expected to see a table like I described.

Instead, I got:
1) all values from the other repeatable group in column 1, but duplicated!
2) a third of the values from the nested repeatable group, and each one has evaluated to <div class="month on"></div>.

#1310143

Hi Eric,

Thank you for contacting us and I'd be happy to assist.

I've performed some tests on my own website, with a similar repeatable field group and fields, but couldn't reproduce the issue shown on your website.

Can you please share temporary admin login details in reply to this message? I'll be in a better position to suggest the best way to achieve this, after checking the views and repeatable field group settings.

Note: Your next reply will be private and though no changes will be made on your website, please make a complete backup copy, before sharing the access details.

regards,
Waqar

#1310905

OK, so I figured out how to eliminate the issue with the repeating values in column 1: it was actually showing the species name field for ALL POSTS. I didn't realize that you had to change the Query Filter setting by adding a post relationship filter...this is so completely non-intuitive. I spent hours troubleshooting until figuring this out.

I've also done something--I have no idea what--to make the nested loop only output a single value (<div class="month on"></div>) in the second column. Therefore it's not looping through the Species Availability checkboxes at all.

This is really frustrating.

#1310917

Now I changed the custom field content for all options in the Species field (it's a Select field). I wanted the content to the the class name which I'll assign to the

  • element, so I made every value lowercase with no spaces.

    This has now stopped the content from appearing in the view output. Now every

  • is blank. WTF.

    I'm getting ready to give up on Toolset....:(

    #1310921

    Hi Eric,

    Thank you for sharing the admin login details and I can now access the backend.

    I can understand the frustration, but I'm confident that I'll have some solution or a workaround to share, after reviewing how everything is set up.

    Can you please hold on making any further changes, during this troubleshooting? This way, I'll be in a better position to understand the requirement and suggest the best way forward.

    regards,
    Waqar

    #1310923

    Sure, I'll move on to something else if I know you're on it.

    #1311191

    Hi Eric,

    Thank you for waiting.

    I've checked both your views ( "Fish Species Calendar" & "Species Availability Calendar (row)") and they both seem to be configured correctly.

    The only missing piece is how to show the "Species Availability" field's selected or unselected values, from the "Species Availability Calendar (row)" view.

    You can choose the custom values for the selected and unselected state, without having to add conditional code blocks individually for each checkbox, right from the field's shortcode, as shown in these screenshots:

    Step 1: hidden link
    Step 2: hidden link
    Step 3: hidden link

    I hope this helps and please let me know if you need any further assistance around this.

    regards,
    Waqar

    #1311595

    Thanks for the suggestion of an alternate way of rendering the selected or unselected state of the "Species Availability" field. I tried this any it works, but one big negative of the method you suggested is that if I ever need to change the class name "month on"/"month off" I would need to change it in 48 different places, as opposed to just a single line with my method. So I would like to understand why my method did NOT work, so that I might be able to get it working later.

    However, I still have the issue of both the "Fish Species List" and "Fish Species Calendar" views that are not outputting the values from the "Species" field. If you say the views are configured correctly, then is there a bug?

    #1312087

    Hi Eric,

    Thanks for sharing the update and glad that you're making progress.

    Repetitions of code, in this case, can't be avoided I'm afraid, because of the "species-availability" field which consists of 24 options, each of which acts pretty much like a separate field.
    ( and each option can have two states; selected and unselected )

    If you'd like to switch back to your original approach of using conditional blocks for each option, this is how it will look like:
    ( ref: https://toolset.com/documentation/user-guides/conditional-html-output-in-views/checking-fields-and-other-elements-for-emptynon-empty-values/#checking-types-checkboxes-field-for-non-empty-value )

    Example:

    
    [wpv-conditional if="( '[types field='field-slug' option='0'][/types]' eq 1 )"]
     <div class="month on">Jan-Mar</div>
    [/wpv-conditional]
    [wpv-conditional if="( '[types field='field-slug' option='0'][/types]' ne 1 )"]
    <div class="month off">Jan-Mar</div>
    [/wpv-conditional]
      
    [wpv-conditional if="( '[types field='field-slug' option='1'][/types]' eq 1 )"]
     <div class="month on">Apr-Jun</div>
    [/wpv-conditional]
    [wpv-conditional if="( '[types field='field-slug' option='1'][/types]' ne 1 )"]
    <div class="month off">Apr-Jun</div>
    [/wpv-conditional]
      
    [wpv-conditional if="( '[types field='field-slug' option='2'][/types]' eq 1 )"]
     <div class="month on">Jul-Sep</div>
    [/wpv-conditional]
    [wpv-conditional if="( '[types field='field-slug' option='2'][/types]' ne 1 )"]
    <div class="month off">Jul-Sep</div>
    [/wpv-conditional]
    
    .......
    
    

    Note: this approach may offer better readability, but note that you'll still have to add two separate conditional code blocks, for each option.

    As for the "Species" field, it is a select type field, but if you'll check "Alaska Trophy Adventures Lodge" post, none of the fish species records has any option selected for this field.
    ( screenshot: hidden link )

    Please select some options for this field and they'll be shown through both your views ( "Fish Species List" and "Fish Species Calendar" ).

    regards,
    Waqar

    #1312687

    OK so what happened is when I changed the "custom field content" value for each item in the select, for some reason it changed the selected value for each instance of the repeating field to be unselected, and I had no idea it did this. So annoying.

    I've re-selected all values for each repeating field instance, so now the field values are showing in the view.

    Thanks for the help. it was desperately needed...I'm finding that Toolset has an enormous learning curve.