Navigation überspringen

[Gelöst] Make the toolset form generic field be searchable

Dieser Thread wurde gelöst. Hier ist eine Beschreibung des Problems und der Lösung.

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 vor 3 Jahre, 7 Monaten. 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 – 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)

Dieses Thema enthält 2 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von kelvinL-2 vor 3 Jahre, 7 Monaten.

Assistiert von: Shane.

Author
Artikel
#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
Unterstützer

Sprachen: Englisch (English )

Zeitzone: 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.

versteckter Link

Thanks,
Shane

#2219135

My issue is resolved now. Thank you!