Skip Navigation

[Résolu] Make the toolset form generic field be searchable

Ce fil est résolu. Voici une description du problème et la solution proposée.

Problem:

The issue here is that the user wanted to integrate the select2 dropdowns for their Toolset forms Generic fields.

Solution:

This can be done by importing the select2 javascript and css library.

Add the following to your custom code snippets at Toolset->Settings-> Custom Code and activate it.

wp_enqueue_script('select2_js', '//cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js', array(), null, true);
wp_enqueue_style( 'select2_css', '//cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css' );

From there you will need to add the following JS to your Form's JS section to enable the select2 for your field.

jQuery(document).ready(function() {
  jQuery('.class-goes-here').select2();
});

Now you will need to replace 'class-goes-here' with the ID/Class of the custom field that is generated on the frontend.

For further information on the usage of Select2 I recommend looking at the documentation below.
https://select2.org/getting-started/basic-usage

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

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

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

Last updated by kelvinL-2 Il y a 2 années et 5 mois.

Assisted by: Shane.

Auteur
Publications
#2214697
Screenshot 2021-11-07 at 12.33.25 AM.png
Screenshot 2021-11-07 at 12.33.17 AM.png

Dear Sir/Madam,

I have a generic field in toolset form, this generic field is a select type and option is generated from a wpv-view

[cred_generic_field type='select' field='product-select']
{
"required":1,
"default":[ "Please select" ],
"options":[ [wpv-view name="product-list-json"] ]
}
[/cred_generic_field]</td>

How can I make this select field same as invoice field which can be searchable?
The invoice field is

[cred_field field='@additional-items.parent' class='form-control' output='bootstrap' select_text='--- Please select invoice number ---' required='true']
#2216183

Shane
Supporter

Languages: Anglais (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Kelvin,

In order for you to achieve this you will need to make use of the select2 functions. Unfortunately this isn't something that is included natively with our Toolset plugins and you will need to import it to your site.

The first thing you will need to do is to add the scripts for select2. Add the following to your custom code snippets at Toolset->Settings-> Custom Code and activate it.

wp_enqueue_script('select2_js', '//cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js', array(), null, true);
wp_enqueue_style( 'select2_css', '//cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css' );

From there you will need to add the following JS to your Form's JS section to enable the select2 for your field.

jQuery(document).ready(function() {
    jQuery('.class-goes-here').select2();
});

Now you will need to replace 'class-goes-here' with the ID/Class of the custom field that is generated on the frontend.
For further information on the usage of Select2 I recommend looking at the documentation below.

hidden link

Thanks,
Shane

#2219135

My issue is resolved now. Thank you!

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