Skip Navigation

[Resolved] Upgrade to Views 1.11 broke a CRED cred_generic_field select populated by a View

This support ticket is created 8 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/Hong_Kong (GMT+08:00)

This topic contains 3 replies, has 2 voices.

Last updated by Rachel 8 years, 5 months ago.

Assisted by: Luo Yang.

Author
Posts
#348298
parent brands select does appear on CRED product create form in Views 1-10-1.PNG
parent brands select not appearing on CRED product create form.PNG

I am trying to: I have a parent Brand custom post type with a child Product custom post type. I have a 'Brands' pulldown/select that shows the parent brands belonging to the logged-in user. It should display on the CRED 'Edit Product Listing' and "Create Product Listing" forms. It was working fine in Views 1.10.1 but does not appear or generate after upgrading to Views 1.11

I visited this URL: hidden link

I expected to see: A pulldown listing the Brands custom posts belonging to the logged-in user.

Instead, I got: A blank space where no pulldown is output.

The pulldown in the CRED form looks like:

		<div class="cred-field cred-field-belongs_brand-listing_id">
			<label class="cred-label">
              Brand:
</label>
          
[cred_generic_field field="_wpcf_belongs_brand-listing_id" type="select" class="" urlparam=""]
{
"required":1,
"validate_format":1,
"persist":1,
"default":["--- Select brand listing ---"],
"options":[[wpv-view name="Brands belonging to this user"]]
}
[/cred_generic_field]
          		</div>

The View output for "Brands belonging to this user" View is

[wpv-layout-start]
	[wpv-items-found]
	<!-- wpv-loop-start -->
	<wpv-loop>
            [wpv-item index=1]{"value":"[wpv-post-id]","label":"[wpv-post-title]"}
      		[wpv-item index=other],{"value":"[wpv-post-id]","label":"[wpv-post-title]"}
	</wpv-loop>
	<!-- wpv-loop-end -->
	[/wpv-items-found]
	[wpv-no-items-found]
		<strong>[wpml-string context="wpv-views"]No brands found[/wpml-string]</strong>
	[/wpv-no-items-found]
[wpv-layout-end]

With Views 1.10.1, the output of the cred_generic_field is

		<div class="cred-field cred-field-belongs_brand-listing_id">
			<label class="cred-label">
              Brand:
</label>
<div class="js-wpt-field-items js-wpt-repetitive wpt-repetitive" data-initial-conditional="" data-item_name="select-_wpcf_belongs_brand-listing_id">
<select id="cred_form_15988_1-select-5-1447880440"  data-wpt-validate="{"required":{"args":{"1":true},"message":"This field is required"}}" data-wpt-field-title="_wpcf_belongs_brand-listing_id" class="wpt-form-select form-select select" data-wpt-type="select" name="_wpcf_belongs_brand-listing_id">
<option value="16585" class="wpt-form-option form-option option" data-wpt-type="option" data-wpt-id="cred_form_15988_1_cred_form_15988_1-select-5-1447880440" data-wpt-name="_wpcf_belongs_brand-listing_id">Clares test brand</option>
<option value="16695" class="wpt-form-option form-option option" data-wpt-type="option" data-wpt-id="cred_form_15988_1_cred_form_15988_1-select-5-1447880440" data-wpt-name="_wpcf_belongs_brand-listing_id" selected="selected">clares test brand 77</option>
<option value="16701" class="wpt-form-option form-option option" data-wpt-type="option" data-wpt-id="cred_form_15988_1_cred_form_15988_1-select-5-1447880440" data-wpt-name="_wpcf_belongs_brand-listing_id">clares test brand 8</option>
</select>
</div>
          		</div>

In Views 1.11, the output is

		<div class="cred-field cred-field-belongs_brand-listing_id">
			<label class="cred-label">
              Brand:
</label>
</div>

like the View isn't outputting, or not being picked up.

#348415

Dear Rachel,

There is a known problem in current version of Views:
Shortcode [wpv-layout-start] and [wpv-layout-end] will output a extra HTML div tag, so you can not use view's result as option of CRED field directly. it is already in our to-do list, I added this thread to raise our developers attention.
Currently, please try to create a custom shortcode to hide the extra div, like this:
1) add below codes into your theme/functions.php

add_shortcode('hide-it', 'hide_it_func');
function hide_it_func(){
	return;
}

2) edit the view "Brands belonging to this user", in section "Loop Output", wrap Shortcode [wpv-layout-start] and [wpv-layout-end] with above custom shortcode [hide-it], like this:

[hide-it][wpv-layout-start][/hide-it]
...
[hide-it] [wpv-layout-end][/hide-it]

Then test again.

#348555

Hooray, I love it when you know exactly what's wrong! And a clever workaround too, awesome. I'll test this out and let you know how it goes.

Thanks so much!

#348686

Worked like a charm. Thanks for the speedy fix!

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