The radio.js in /administrator/your_coook_component/dom/assets/bootstrap/js/radio.js doesn't do its job as i would like him to do.
It works fine if there's only two choices (boolean, shows green button when you click on Yes, red button when you click on No)
But if you have more choices, like an enumeration field that is configured to display as Radio, then it all falls appart : the last button becomes green when clicked (because it's related to the 1 of the boolean i guess), but other buttons receive btn-undefined as class.
Here is my version of radio.js : i loose red/green in boolean (choice i make is always green), but it works with everything i throw at him.
(function($){
var colors = {'':'primary','0':'danger','1':'success'};
$('document').ready(function(){
$(".btn-group label").click(function() {
var label = $(this);
var input = $('#' + label.attr('for'));
if (!input.prop('checked')) {
label.closest('.btn-group').find("label").removeClass('active'
+ ' btn-' + colors['']
+ ' btn-' + colors['0']
+ ' btn-' + colors['1']);
//label.addClass('active btn-' + colors[input.val()]);
label.addClass('active btn-success');
input.prop('checked', true);
}
});
$(".btn-group input[checked=checked]").each(function() {
//$("label[for=" + $(this).attr('id') + "]").addClass('active btn-' + colors[$(this).val()]);
$("label[for=" + $(this).attr('id') + "]").addClass('active btn-success');
});
});
})(jQuery);