Adding conditions to content groups

Hi guys,

I would like to show or hide individual groups in a repeater as needed. It is important to me that they do not appear in the dropdown menu of the “add button”.

Would it be possible to apply conditions to content groups in a blueprint… or is there another way to accomplish this?

@Amin, it would be possible to extend the configuration to remove the group definitions on the repeater form widget. Using the model.form.filterFields event. Here is an example:

$model->bindEvent('model.form.filterFields', function ($formWidget, $fields, $context) {
    $fields->myrepeater->groups = array_except($fields->myrepeater->groups, ['foo', 'bar']);

Feel free to Contact Us - October CMS if you need help with this.

@daft, Thanks for your answer and your example.
Unfortunately I can’t get it to work. I have pasted my code into the plugin boot function. When I do a dump of the array the selected groups are gone. However, on the page in the backend they are still visible and also usable. What am I doing wrong?

@Amin, to confirm: are you using the latest version?

Step 1 of troubleshooting should always be to try in the latest version because the platform evolves quickly, and filtering repeaters was recently improved.

@daft, yes, I use the latest version (v3.3.8)

1 Like