Skip Navigation

[Resolved] CRED Select Parent using view – extra select line with label of n

This support ticket is created 7 years, 4 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
- 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 11 replies, has 2 voices.

Last updated by tony 7 years, 4 months ago.

Assisted by: Nigel.

Author
Posts
#468789

I have referred to two previous support posts:

https://toolset.com/forums/topic/upgrade-to-views-1-11-broke-a-cred-cred_generic_field-select-populated-by-a-view/
https://toolset.com/forums/topic/add-record-form-parent-dropdown/

to use a view to reduce the number of selectable parent records in a CRED form.

It works fine except for one thing.

An extra line appears in the select dropdown (at the end):

<option value="default" class="wpt-form-option form-option" data-wpt-type="option" data-wpt-id="cred_form_8387_2_cred_form_8387_2-select-1-1482076665" data-wpt-name="_wpcf_belongs_event_id">n</option>

There is no event "n" and my default does not seem to show "--- Select Event ---" so I am probably doing something wrong somewhere.

I cannot see what is generating this line so any suggestions would be welcome.

VIEWS 2.2.2
CRED 1.8.4
WP 4.7

Many thanks
Tony

======================================================================

My settings for the CRED generic field are:

[cred_generic_field field="_wpcf_belongs_event_id" type="select" class="" urlparam=""]
{
"required":1,
"validate_format":1,
"persist":1,
"default":["--- Select Event ---"],
"options":[[wpv-view name="select-events-for-dropdown"]]
}
[/cred_generic_field]

======================================================================

I checked the view results and the default line does not appear.

My views code is:

[hide-it][wpv-layout-start][/hide-it]
[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]
[wpml-string context="wpv-views"][/wpml-string]
[/wpv-no-items-found]
[hide-it][wpv-layout-end][/hide-it]

======================================================================

The full dropdown code in the page is:

<div class="js-wpt-field-items form-group js-wpt-repetitive wpt-repetitive" data-initial-conditional="" data-item_name="select-_wpcf_belongs_event_id">
<select id="cred_form_8387_2-select-1-1482076665" cred_generic="1" dummy="default" data-wpt-validate="{"required":{"args":{"1":true},"message":"This field is required"}}" data-wpt-field-title="_wpcf_belongs_event_id" class="wpt-form-select form-select form-control" data-wpt-type="select" name="_wpcf_belongs_event_id">
<option value="" class="wpt-form-option form-option" data-wpt-type="option" data-wpt-id="cred_form_8387_2_cred_form_8387_2-select-1-1482076665" data-wpt-name="_wpcf_belongs_event_id" selected="selected">--- not set ---</option>
<option value="8238" class="wpt-form-option form-option" data-wpt-type="option" data-wpt-id="cred_form_8387_2_cred_form_8387_2-select-1-1482076665" data-wpt-name="_wpcf_belongs_event_id">2017 Club Sailing (May-28)</option>
<option value="8236" class="wpt-form-option form-option" data-wpt-type="option" data-wpt-id="cred_form_8387_2_cred_form_8387_2-select-1-1482076665" data-wpt-name="_wpcf_belongs_event_id">2017 Club Sailing (May-21)</option>
<option value="8235" class="wpt-form-option form-option" data-wpt-type="option" data-wpt-id="cred_form_8387_2_cred_form_8387_2-select-1-1482076665" data-wpt-name="_wpcf_belongs_event_id">2017 Club Sailing (May-14)</option>
<option value="7828" class="wpt-form-option form-option" data-wpt-type="option" data-wpt-id="cred_form_8387_2_cred_form_8387_2-select-1-1482076665" data-wpt-name="_wpcf_belongs_event_id">2017 NEYTS (North-east Youth Travellers)</option>
<option value="8197" class="wpt-form-option form-option" data-wpt-type="option" data-wpt-id="cred_form_8387_2_cred_form_8387_2-select-1-1482076665" data-wpt-name="_wpcf_belongs_event_id">2017 Club Sailing (May-07)</option>
<option value="8189" class="wpt-form-option form-option" data-wpt-type="option" data-wpt-id="cred_form_8387_2_cred_form_8387_2-select-1-1482076665" data-wpt-name="_wpcf_belongs_event_id">2017 Club Sailing (Apr-30)</option>
<option value="8187" class="wpt-form-option form-option" data-wpt-type="option" data-wpt-id="cred_form_8387_2_cred_form_8387_2-select-1-1482076665" data-wpt-name="_wpcf_belongs_event_id">2017 Club Sailing (Apr-23)</option>
<option value="8178" class="wpt-form-option form-option" data-wpt-type="option" data-wpt-id="cred_form_8387_2_cred_form_8387_2-select-1-1482076665" data-wpt-name="_wpcf_belongs_event_id">2017 Club Sailing (Apr-16)</option>
<option value="8177" class="wpt-form-option form-option" data-wpt-type="option" data-wpt-id="cred_form_8387_2_cred_form_8387_2-select-1-1482076665" data-wpt-name="_wpcf_belongs_event_id">2017 Club Sailing (Apr-09)</option>
<option value="8169" class="wpt-form-option form-option" data-wpt-type="option" data-wpt-id="cred_form_8387_2_cred_form_8387_2-select-1-1482076665" data-wpt-name="_wpcf_belongs_event_id">2017 Club Sailing (Apr-02)</option>
<option value="8345" class="wpt-form-option form-option" data-wpt-type="option" data-wpt-id="cred_form_8387_2_cred_form_8387_2-select-1-1482076665" data-wpt-name="_wpcf_belongs_event_id">2017 Working Party 1</option>
<option value="7825" class="wpt-form-option form-option" data-wpt-type="option" data-wpt-id="cred_form_8387_2_cred_form_8387_2-select-1-1482076665" data-wpt-name="_wpcf_belongs_event_id">2017 Annual General Meeting</option>
<option value="7912" class="wpt-form-option form-option" data-wpt-type="option" data-wpt-id="cred_form_8387_2_cred_form_8387_2-select-1-1482076665" data-wpt-name="_wpcf_belongs_event_id">Artists Wanted!</option>
<option value="7580" class="wpt-form-option form-option" data-wpt-type="option" data-wpt-id="cred_form_8387_2_cred_form_8387_2-select-1-1482076665" data-wpt-name="_wpcf_belongs_event_id">2016 EOS Social (Nov 26)</option>
<option value="7583" class="wpt-form-option form-option" data-wpt-type="option" data-wpt-id="cred_form_8387_2_cred_form_8387_2-select-1-1482076665" data-wpt-name="_wpcf_belongs_event_id">2016 Grassholme Shed Delivery</option>
<option value="5993" class="wpt-form-option form-option" data-wpt-type="option" data-wpt-id="cred_form_8387_2_cred_form_8387_2-select-1-1482076665" data-wpt-name="_wpcf_belongs_event_id">2016 Working Day 4</option>
<option value="default" class="wpt-form-option form-option" data-wpt-type="option" data-wpt-id="cred_form_8387_2_cred_form_8387_2-select-1-1482076665" data-wpt-name="_wpcf_belongs_event_id">n</option>
</select>
</div>

======================================================================

#468968

Nigel
Supporter

Languages: English (English ) Spanish (Español )

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

Hi Tony

I reproduced this on a test site but I couldn't reproduce the issue with the additional 'n' option.

I notice looking at the markdown for the dropdown you reproduced in your question that this 'n' option is marked as the default option.

I had to read through the CRED source code to double check how the default option is supposed to work (sorry, the documentation is not very helpful here), and the default option is not intended to be the first empty option (e.g. "Please select a parent"), it is intended to work as a pre-selection, e.g. you have options 1 to 10 and the default option 5 is pre-selected, so you would set default as the value of option 5.

Try removing your default setting and seeing if that helps.

The only other difference I had on my test site is on the no items found section of the loop output of the view, which is empty (whereas yours contains the wpml-string shortcodes).

Let me know how you get on so that I can think about how to proceed if needs be.

#469099

Thanks Nigel

I tried removing
"default":["--- Select Event ---"],

no change

I then tried
"default":1,

Still no change.

I am aware that there may be an issue with nothing found.

Something is adding that last default line and I cannot see how to stop it appearing - I don't have a default.

Tony

#469116

Nigel
Supporter

Languages: English (English ) Spanish (Español )

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

Hi Tony

I don't see any debug info to know your setup (https://toolset.com/faq/provide-debug-information-faster-support/). As I can't replicate the problem, can we please eliminate possible conflicts before I go any further?

Can you switch theme to a default theme such as twentysixteen and re-test, and disable all non-Toolset plugins and re-test.

If that doesn't help I may need to take a copy of your site for testing, but I'll wait to hear back from you first.

#469136

OK

I am using Toolset Starter them. I deactivated all plugins except Toolset and the dropdown line still appears.

Here is the debug information (I hope I got this right).

If you cannot spot anything odd then let me do some more investigation. This is the first time I have tried to use a view in a CRED form. I will try another view and see if the problem persists.

Thanks
Tony

#469340

Hi Nigel

I set up a new test site and page
hidden link

The only active plugins are Types, Views and Cred. The theme is Toolset Starter but the same problem exists in TwentyFifteen.

The view output is at the top of the page (filtered with Hide-It).

The standard CRED dropdown is Date Parent. The generic field is underneath.

It looks like the code that displays the CRED form is being triggered by something that is creating and extra select line.

Tony

#469348

Nigel
Supporter

Languages: English (English ) Spanish (Español )

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

Hi Tony

Can I get credentials to look at that test site you have set up?

I will mark your next reply as private so that I can get log-in credentials from you—you may want to create a temporary admin user for me to use that you can later delete. And be sure to have a current backup of your site, even though I don't intend to make any changes other than to inspect the set up and possibly temporarily add a backup plugin to take a snapshot of the site.

#469352

sent

#469456

Nigel
Supporter

Languages: English (English ) Spanish (Español )

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

Hi Tony

I'm puzzled by what I see and so I'm taking a copy of the site so I can test it locally.

I will update you when I find anything.

#469942

Nigel
Supporter

Languages: English (English ) Spanish (Español )

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

Hi Tony

I had troubles making a copy of your site, which is often something of a red flag that there is a problem with the installation. Duplicator and All in One WP migration both failed, but I eventually managed to make a partial copy of the site with WP Clone. I still had to export then import the content manually.

And the view and CRED form didn't make it across either, which meant I had to create them from scratch.

I did that and re-tested the issue, and couldn't reproduce it. The extra line with the 'n' is no longer present.

I'm not sure what specifically on the set up on your server is creating the problem, but I can't reproduce the problem on a clean install nor on your cloned/re-built site on a different server.

You may want to spin up a new installation and import your content across from the existing server, in which case I would not expect you to see the problem again.

You can see the cloned/re-built site (using twentyseventeen) here: hidden link

#470031

Thanks for having a look at this Nigel. As you say, it could be something odd with our installation and so will have someone take a look to see if they can spot any problems.

I will also use a completely different server with andother service provider to see if the problem exists there.

Many thanks again.

Tony

#470344

The second server worked fine so the prolem is with my set up.

I will investigate and see if I can find out where the problem is.

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