Only one value selecteable in list filter type: group

I faced this issue quite some times with the OctoberCMS Backend List Filters:

I have several values which can be selected in a filter (for ex some categories), but I only want the user to select one value at a time, not several as it would be with this config:

    category:
        type: group
        modelClass: Mch\Wiki\Models\Category
        label: 'mch.wiki::lang.terms.category'
        conditions: category_id in (:filtered)

Cause when I selected “Category 1” within this filter and wanna switch, I’ve to open the filter (click 1), deselect Category 1 (Click 2), select Category 2 (Click 3) and click “Apply” (Click 4).

It would be a lot easier, if there would be an additional option like “select_max: X” which limits the amount of items to select in a filter and if it’s set to 1, you can only switch between categories and you dont have to do all the clicking from above.

Ofc it would also be enough if it’s not “select_max: X” but just “only_select_one_entry: true”.

Let me know if I missed an option which allows doing this, but I didnt find any…

Hey @LordRazen, the dropdown filter scope is used for selecting one value:

1 Like

Honestly… how could it be that I read through the docu for 10 months now and missed that!? :smiley:

Ok, thanks a lot.

While implementing this, I think I recognized a bug which is similar to the bug we talked on Discord before:

If you have an option with the value 0, the dropdown does not work correctly.

Here’s an example:
This is my options array from the Model:

    public function getTypeOptions()
    {
        return [
            0 => 'Default Option',
            1 => 'Option 1',
            2 => 'Option 2',
        ];
    }

This here is my filter:


    type:
        type: dropdown
        modelClass: Me\Plugin\Models\MyModel
        emptyOption: '-- empty --'
        options: getTypeOptions
        conditions: type = :value

Now when I select option 1 or 2, everything works fine, but if I select the Default Option with the value 0, the filter does not filter for 0, it shows all.

Got it. Should be fixed in the next patch.

1 Like