I know that "readonly" feature does not exist for select2. Please check here. How do I achieve that? Any help would be appreciated. Thanks. Note: I cant use disabled. If I use disabled, I will not get the list of selected value.
I guess that issue is resolved or may be available for higher version as this worked for me.
Please go through the example to make a select2 readonly here: Select 2
In js code:
$("select").select2("readonly", true);
You can put your own CSS like:
.select2-container.select2-container-disabled .select2-choice {
background-color: #ddd;
border-color: #a8a8a8;
}
$('.js-example-basic-single').select2({
disabled: true
});
Render a disabled attribute after the page loads resolved for me.
A reminder, a field with the disabled attribute is not sent on forms
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With