Home › Forums › Backend Issues (wp-admin) › ACF Javascript API – Dynamically Update select2 Field Options › Reply To: ACF Javascript API – Dynamically Update select2 Field Options
The hook acf.addAction('select2_init', function( $select, args, settings, field ){
is perfect and it would allow me to assign the correct language settings to all fields by using args['language'] = 'xx';
and by integrating this
$.fn.select2.amd.define('select2/i18n/xx',[],function () {
return {
errorLoading: function () {
return acf.__('the results could not be loaded.');
},
inputTooLong: function (args) {
var overChars = args.input.length - args.maximum;
var message = acf.__('please delete') + ' ' + overChars + ' ' + acf.__('character');
if (overChars != 1) {
message += 's';
}
return message;
},
inputTooShort: function (args) {
var remainingChars = args.minimum - args.input.length;
var message = acf.__('please enter') + ' ' + remainingChars + ' ' + acf.__('or more characters');
return message;
},
loadingMore: function () {
return acf.__('loading more results…');
},
maximumSelected: function (args) {
var message = acf.__('you can only select') + ' ' + args.maximum + ' ' + acf.__('item');
if (args.maximum != 1) {
message += 's';
}
return message;
},
noResults: function () {
return acf.__('no results found');
},
searching: function () {
return acf.__('searching...');
},
removeAllItems: function () {
return acf.__('remove all items');
},
removeItem: function () {
return acf.__('remove item');
},
search: function() {
return acf.__('search');
}
};
});
but the new problem is that now all select2 fields have more hight than before – it seems that they lost the styling…….
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.