Description
Filter used to provide the ability to change default configuration settings for the Modern Dropdown form field.
Parameters
- $config
- (array) Array of default configuration settings used for the dropdown.
- $forms
- (int) Form ID.
Source
wpforms/includes/fields/class-select.php
More Information
The wpforms_field_select_choicesjs_config
has default configuration set such as the text Loading, No Results, Item Select and others. A full list of text values and their key names can be seen below.
'loadingText' => esc_html__( 'Loading...', 'wpforms-lite' ),
'noResultsText' => esc_html__( 'No results found.', 'wpforms-lite' ),
'noChoicesText' => esc_html__( 'No choices to choose from.', 'wpforms-lite' ),
'itemSelectText' => esc_attr__( 'Press to select.', 'wpforms-lite' ),
'uniqueItemText' => esc_html__( 'Only unique values can be added.', 'wpforms-lite' ),
'customAddItemText' => esc_html__( 'Only values matching specific conditions can be added.', 'wpforms-lite' ),
Example
/** * Configuration text settings for Modern Dropdown form field. * * @link https://wpforms.com/developers/wpforms_field_select_choicesjs_config/ * * @param array $config * @param int $forms * * @return array */ function wpf_dev_change_modern_dropdown_noresults_text( $config, $forms ) { // Change 1369 to an ID of your actual form. if ( array_key_exists( 1369, $forms ) ) { // If there are several forms on the same page, the customization will be applied to all of them. $config[ 'loadingText' ] = __( 'Searching....', 'your-text-domain' ); } return $config; } add_filter( 'wpforms_field_select_choicesjs_config', 'wpf_dev_change_modern_dropdown_noresults_text', 10, 2 );
Related
Tutorial References: