Home › Forums › Backend Issues (wp-admin) › Disabled JS input (Select, User, …) Save as empty › Reply To: Disabled JS input (Select, User, …) Save as empty
I found a solution by myself. Some input type as Chekbox type have an additional hidden input so I need to disabled all the input used by ACF.
Exemple for Chekbox :
add_filter('acf/prepare_field', 'edit_prepare_field');
function edit_prepare_field( $field ) {
...
case 'checkbox':
$field['wrapper'] = array('width'=> $width,'class'=> 'disabled_checkbox');
$field['readonly'] = 1;
break;
...
return $field;
}
function read_only_field_javascript() {
...
$('.disabled_checkbox select').prop('disabled','disabled');
$('.disabled_checkbox input').prop('disabled','disabled');
...
}
User field is more complex (use <span> for exemple) and can’t be disabled by the previous methode, some other like gallery can really be disabled so I change the field type to “enhanced_message” and display the value with some PhP.
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.