Skip Navigation

[Fermé] CRED Forms – Parent Selector Fields

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.

This topic contains 9 réponses, has 2 voix.

Last updated by Adriano Il y a 7 années et 6 mois.

Assigned support staff: Adriano.

Auteur
Publications
#219412
screenshot3.png
screenshot2.png
screenshot1.png

Hi

I am having an issue to set the parent selector field of a CRED form that is set up to create child content of a parent content. This is what I've uses in the CRED form:

[cred_field field="_wpcf_belongs_merchant_id" value="" order="date" ordering="desc" no_parent_text="No Parent"] (screenshot2)

What this does is to give the user an option choose from all parents available. However, what I want is only the parent assigned to to the logged in user to be available. (screenshot1)

(There is a merchant type (parent) and a coupon type (child). I am currently working on a My Account area for the logged in merchants to post coupons for their own business only)

PS. I have also tried without the Parent Selector Field and what it does then is to create the coupon, however, does not assign it to the merchant automatically (screnshot3)

I have also played around with the options, including the current parent, but I could not make it work.

Thanks

#219426

Dear James,

Ana, our CRED expert developer wrote an insteresting article in our blog about it, please take a look and let me know if it helps: https://toolset.com/2013/10/conditional-display-of-parent-posts-in-cred/

#219446

Hi Adriano

Thanks for the link; however, I have to say I am less than a beginner at coding.

I will give it my best shot and let you know.

Thanks

#219466

Hi Adriano
I have tried to follow Ana's instructions:

1- I have created a view for “my merchants listing?? for “currently logged in user??:
<div id="aux_merchants_list" style="display:none">
<wpv-loop>
<div>[wpv-post-id]</div>
</wpv-loop>
</div>

2- Then I inserted it in the CRED form and also added the merchant parent field:

[wpv-view name="my merchants listing"]

[cred_field field="_wpcf_belongs_merchant_id" value="" order="date" ordering="desc" no_parent_text="No Parent"]

3- Then added the JQuery

jQuery(document).ready(function($) {
try {
var select = $('select[name="_wpcf_belongs_merchant_id"]');
var list = $('#aux_merchants_list') || $('div id="aux_merchants_list"></div>');
if (select.length) {
var selected = select.val();
var new_select = select.clone(true, true);
new_select.children().remove();
$('.aux_id', list).each(function(index, element) {
var id = $(element).text() || 0;
$('option[value="' + id + '"]', select).appendTo(new_select);
});
new_select.val(selected);
select.replaceWith(new_select);
}
} catch(e) {
}
});

And it is still showing all merchants, not the merchant of the logged in user?

Can you see where I am going wrong?

Thanks

#219471

Just a quick correction to the above message. Now it is not showing any merchants at all. Thanks

#219726

Dear James,

I would like to check your site to understand the elements you are using, it will be more easy to help you to implement this advanced feature. Could you share credentials of the site? I've just enabled the private area for you, please fill the required fields.

#219753
asamplemerchantpostscreen.jpg
thisishowtheformlookslik.png
addcouponcredform.jpg
mymerchantslistingview.jpg

Hi Adriano

I am testing the site on a local host so unfortunately I won't be able to give access to it. However, I have added a few screenshot stitched together, hoping that it would help you understand what I have done so far.

Thanks

#220009

Dear James,

I've just found a error on this article. You should the content of the view, currently it is:

<div id="aux_musicians_list" style="display:none">
  <wpv-loop>
    <div>[wpv-post-id]</div>
  </wpv-loop>
</div>

The correct one is:

<div id="aux_musicians_list" style="display:none">
  <wpv-loop>
    <div class="aux_id">[wpv-post-id]</div>
  </wpv-loop>
</div>

Please change it and let me know if it works.

#220110

Hi Adriano

I've tried that and it did not work. HTML output of the form is something like this:

<div id="aux_merchants_list" style="display:none">

<div class="aux_id">555</div>

</div>
<!-- wpv-loop-end -->

<select name="_wpcf_belongs_merchant_id" id="cred_form_555_1__wpcf_belongs_merchant_id" class="myzebra-control myzebra-select myzebra-prime-name-_wpcf_belongs_merchant_id"><option value="-1">No Parent</option><option value="555">Add Coupon</option></select>

Somehow, it does not bring up the page ID of the merchant posts but the ID of the CRED form.

And the dropdown box in the box shows the name of the cred for (Add Coupon)

Also, the article, after inserting the aux view to the CRED form, talks about inserting a select field into the form, which I could not workout how to do:
"make sure you have added the field for listing parent post in your CRED form. The select field will display the following HTML output:
<select name="_wpcf_belongs_musicians_id" id="cred_form_15_1__wpcf_belongs_musicians_id" class="myzebra-control myzebra-select myzebra-prime-name-_wpcf_belongs_musicians_id">
<option value="-1">-- choose a musician --</option>
<option value="292">Musician #6</option>
<option value="290">Musician #5</option>
<option value="14">Musician #4</option>
<option value="13">Musician #3</option>
<option value="12">Musician #2</option>
<option value="9">Musician #1</option>
</select>"

Instead I have inserted merchant Parent from the Insert Post Fields link of the CRED form. (Not sure, the problem may be here)

Thanks

#220347

Dear James,

It is strange, I can not any error in your procedures. If I follow all procedures of the blog post I can make it works fine. Could you prepare an online version so can I show you it working?

Le sujet ‘[Fermé] CRED Forms – Parent Selector Fields’ est fermé à de nouvelles réponses.