Skip Navigation

[Résolu] Multiselect forms, displaying the data, editing the multi select

This support ticket is created Il y a 5 années. 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.

Aucun de nos assistants n'est disponible aujourd'hui sur le forum Jeu d'outils. Veuillez créer un ticket, et nous nous le traiterons dès notre prochaine connexion. Merci de votre compréhension.

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)

Ce sujet contient 7 réponses, a 3 voix.

Dernière mise à jour par stuart Il y a 4 années et 11 mois.

Assisté par: Luo Yang.

Auteur
Publications
#1399269

I have a custom post type called "Integrations"

On this page I would like to have a list of our integration partners that are sort-able based on the criteria they select when using a CRED from.

The CRED form should to allow them to multi-select what "industries" they serve, what "locations" they serve.

Now, I can setup the generic cred field for multi select that pulls from a Toolset view that list the Industries fine (and using Selec2)

<label>Industries Serviced</label>
[cred_generic_field type='multiselect' field='partner-service-industries' class='partner-service-industries']
{
"required":0,
"options":[[wpv-view name="partner-industries-select"]]
}
[/cred_generic_field]

What I am unsure about is if this is the best method (maybe I should use a taxonomy?) and how I store multi select data in a Types field (or maybe this should not be stored in a types field?)

I was going to use a repeating field, but then I thought to myself this will make the admin section of each custom post unmanageable (100+ options on each) - and how would display and use this in a CRED edit form on the front end.

Using check boxes would also result in a similar experience ... so I am strugling to work it out.

- some other notes:

I would like the CRED edit of the page to allow Integration Partners to select and deselect values where appropriate.

I would also like the back end admin to have the same multi select options where possible.

How do I go about achieving this? Or even can I?

And If I cant, do you know of any other ways that I could ...

Thanks

#1399481

Minesh
Supporter

Les langues: Anglais (English )

Fuseau horaire: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

What I am unsure about is if this is the best method (maybe I should use a taxonomy?) and how I store multi select data in a Types field (or maybe this should not be stored in a types field?)
===>
I would like to know-how the "partner-service-industries" field is setup using Types plugin? is it a custom field or post type in relationship?

I would like the CRED edit of the page to allow Integration Partners to select and deselect values where appropriate.
==>
What do you want to allow to select/deselect?

I would also like the back end admin to have the same multi select options where possible.
==>
Can you please clarify for which field you want to allow multi-select?

How do I go about achieving this? Or even can I?
==>
I need to understand first your current structure and what is your expected results and what is the flow so that I can guide you in the right direction.

#1400287

Stuart: ------> All of what I mention below can be changed if you can advise me the best workflow to satisfy my needs 🙂

What I am unsure about is if this is the best method (maybe I should use a taxonomy?) and how I store multi select data in a Types field (or maybe this should not be stored in a types field?)
===>
I would like to know-how the "partner-service-industries" field is setup using Types plugin? is it a custom field or post type in relationship?

Stuart: ------> This is currently a single select, repeating field (but this will need to change, as it's could contain over 100 entries and will make the admin of the post hard to manage - especially if there are multiple repeating fields.

Field: lien caché
What it looks like in wp-admin on the custom post page: lien caché

I would like the CRED edit of the page to allow Integration Partners to select and deselect values where appropriate.
==>
What do you want to allow to select/deselect?

Stuart: ------> On the front end of the site in a CRED edit form I would like the partner to make changes where necessary
lien caché

I would also like the back end admin to have the same multi-select options where possible.
==>
Can you please clarify for which field you want to allow multi-select?
Stuart: ------> its the same field as above and I would like to have it behave the same so it maximizes the amount of space
lien caché

I believe this will require some custom code which is fine, Its probably like this (and maybe this is an option to use the plugin and send the CRED data to the field created by this guys plugin?)
lien caché

How do I go about achieving this? Or even can I?
==>
I need to understand first your current structure and what is your expected results and what is the flow so that I can guide you in the right direction.

Stuart: ------> no problem, I hope I have explained it in the previous answers if not, one more time below.

Front End:

CRED NEW Post form with multi-select options - Partner can multi-select with industries they belong too

CRED EDIT Post form with multi-select options - Partner can modify/edit the multi-select options - in the same way as above.

View on Front End - A website visitor can filter the view based on the Industries the Partner set in the previous forms.

Back End

Site Admin - a website admin (me) can use the WordPress admin backend to modify the Industry select option (rather than going through the CRED edit forms) - however, I am happy to forgo this if it's too hard and just use the CRED edit, new post forms.

Notes:
I am happy to use a Taxonomy if that is the best way to store the multi-select data, or create a relationship if that's the best option, or something else 🙂

Cheers Minesh 🙂

#1400407

Hello,

Minesh is on vacation, I will take care of this ticket.

Thanks for the details, Toolset Types plugin supports custom checkboxes field, it is a multi-select options field.
I assume you need display some extra information for each "partner-service-industries" item.

In your case, I suggest try with custom taxonomy:
1) Setup post type "Integrations"
2) Setup custom Hierarchical taxonomy "partner-service-industries", and register it to above post type "Integrations", if you need setup additional information to terms of taxonomy "partner-service-industries", you can also setup some term fields to taxonomy "partner-service-industries"
https://toolset.com/documentation/user-guides/create-custom-taxonomies/
3) Setup post forms for creating/editing "Integrations" post, put taxonomy field "partner-service-industries" into form content,
So it will be display as custom checkboxes field by default, see our document:
https://toolset.com/documentation/user-guides/cred-shortcodes/#cred_field
display. Optional. Used by fields for Hierarchical Taxonomies (like Categories) to signify the mode of display (ie. “select” or “checkbox”).

#1403553

Hi guys - thanks for the assistance, as ever one question leads in to another... 🙂 [See bottom - Other Related Question]

I have this working - I have a custom post type, with associated taxonomy.

My CRED form uses the taxonomy field with Select2 in a multi select operation - this can then be displayed and edited on the front end - Ill give some more context for those that come across this form them selves.

- You want to create a multi select field and use CRED new post and CRED edit post to allow the users add and modify multi select field choices.

Setup your post type, setup your taxonomy and connect them together - add the taxonomy values.

Create your CRED new post form (the edit will be a copy of this).

In the Advance editor you will add your taxonomy field like this:

<div class="row">
<div class="col-sm-12">
[cred_field field='testonomy' force_type='taxonomy' output='' display='select']
<!-- OPTIONAL select all values check box -->
<input type="checkbox" id="checkbox" >Select All
</div>

in the JS editor [AFTER you have loaded the Select2 library to WordPress]

Below in the name= " id = $("select[name='testonomy[]']").attr('id');" change to be what ever your taxonomy name is above in the field name in the CRED form.

Also below there is an optional check box - this is to select all values or deselect all values if you have a big list... dont forget to change the id if you change it above, to the same name below in the jQurey below.

[code]
jQuery(document).ready(function($){
id = $("select[name='testonomy[]']").attr('id');
$("#"+id).select2();
<!-- Optional select all check box, remove this down to the curly brackets where is says HERE, if you dont want this, ensuring you have closed the function. -->
$("#checkbox").click(function(){
if($("#checkbox").is(':checked') ){
$("#"+id+" > option").prop("selected","selected");
$("#"+id+" > option").trigger("change");
}else{
$("#"+id+" > option").prop("selected",false);
$("#"+id+" > option").trigger("change");
// $("#"+id+" > option").val(null).trigger('change');
} //HERE
});
[/code]

EXTRA - if you use this in the CSS editor you will remove the selected options from being displayed when you try to add another - youll get it once you try it.
[code].select2-results__option[aria-selected=true] { display: none;}[/code]

[Other Related Question]

Ive opened a new ticket and linked it from here for ease of reference.
https://toolset.com/forums/topic/cred-form-generic-field-not-saving-taxonomy-data-cred_save_data/

Basically I want to be able to do the same but with Generic fields and populating taxonomies associated to the CPT.

Cheers guys 🙂

#1403559

Code above need amending as it needed closing brackets, here it is

jQuery(document).ready(function($){
id = $("select[name='testonomy[]']").attr('id');
$("#"+id).select2();
// Optional select all check box, remove this down to the curly brackets where is says HERE, if you dont want this, ensuring you have closed the function.
$("#checkbox").click(function(){
if($("#checkbox").is(':checked') ){
$("#"+id+" > option").prop("selected","selected");
$("#"+id+" > option").trigger("change");
}else{
$("#"+id+" > option").prop("selected",false);
$("#"+id+" > option").trigger("change");
} //HERE
});
});

#1403601

Thanks for sharing the codes and workaround, that will help other users here.

For your other new questions, please check your new thread.

#1404111

My issue is resolved now. Thank you!