Forum

Thread tagged as: Question, Suggestions

Display categories as radio buttons

Is it possible to display categories as radio buttons instead of checkboxes?

David Newton

David Newton 0 points

  • 7 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Not currently. That would limit your choices to 1, of course.

Yup, that's exactly what I need to do. Can I please officially request this as a feature?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Yup, sure.

I need this as well please.

David (@newto6), if you are interested, I have sorted this by adding some jquery instead which basically only allows one checkbox to be checked at any one time.

In perch/addons/plugins/ui/_config.inc (or whatever you have named your perch folder, if applicable) and add in a link to a jquery file (in my case I have made a new file specifically for the perch admin and minified it):

<script src="path_to_your_jquery_file/jquery_file_name.js"></script>

Then in the jquery file, I have this:

$(document).ready(function() {

    $('.check').on('click', function(){
        var checkbox_id = $(this).attr('id');
        $("input:checkbox.check").each(function(){
            var $this = $(this);    
            if($this.is(":checked") && $this.attr('id') !== checkbox_id){
                $this.attr('checked', false);
            }
        });
    });

});

This has worked like a charm for me :)