Description
Le wpforms_field_select_choicesjs_config
est utilisé pour permettre de modifier les paramètres de configuration par défaut de l'application Dropdown moderne champ du formulaire.
Paramètres
- $config
- (tableau) Tableau des paramètres de configuration par défaut utilisés pour la liste déroulante.
- Formulaires
- (int) ID du formulaire.
Source
wpforms/includes/fields/class-base.php
Plus d'informations
Le filtre dispose d'une configuration par défaut telle que le texte Chargement, Pas de résultats, Sélection d'éléments et autres. Une liste complète des valeurs de texte et de leurs noms de clés est présentée ci-dessous.
'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' ),
Exemple
/** * Configuration text settings for the 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 519 to an ID of your actual form or remove this condition to apply to all forms. if ( ! array_key_exists( 519, $forms ) ) { return $config; } // If there are several forms on the same page, the customization will be applied to all of them. $config[ 'loadingText' ] = __( 'Searching....', 'your-text-domain' ); $config[ 'noResultsText' ] = __( 'Nothing to be found', 'your-text-domain' ); $config[ 'noChoicesText' ] = __( 'These are not the choices you are looking for', 'your-text-domain' ); $config[ 'itemSelectText' ] = __( 'Select me', 'your-text-domain' ); $config[ 'uniqueItemText' ] = __( 'Only unique values can be added.', 'your-text-domain' ); $config[ 'customAddItemText' ] = __( 'Only values matching specific conditions can be added.', 'your-text-domain' ); $config[ 'searchResultLimit' ] = 2; return $config; } add_filter( 'wpforms_field_select_choicesjs_config', 'wpf_dev_change_modern_dropdown_noresults_text', 10, 2 );