MostGenerator icon indicating copy to clipboard operation
MostGenerator copied to clipboard

Categories categorisableMultiSelection choice per registered property name

Open ThiloWitt opened this issue 6 years ago • 4 comments

Q A
ModuleStudio Version [1.4.0]
Operating System [Windows]
Zikula Target in Model [ZK20]
Zikula Version [2.0.x]
PHP Version [7.0.x]

Summary MOST allows to active categorisableMultiSelection per entity = all categories of an entity show either the single or the multi selection feature. When more than one category properties are registered for a module in Categories / category registry, some of them might need to work with SingleSelection, which is not possible in the current situation.

Desired Behavior Allow to chose between single and multi selection per category property.

Possible Solution Move the option categorisableMultiSelection to the category registry of the Categories module

ThiloWitt avatar Mar 29 '19 10:03 ThiloWitt

Note: the generated CategoryHelper already provides a hasMultipleSelection method which allows to decide for each entity and property/registry whether multi selection should be possible or not.

Guite avatar Mar 31 '19 15:03 Guite

I see "public function hasMultipleSelection" in AbstractCategoryHelper.php. I would need an example of how a "Subclass can override this method to apply a custom behaviour to certain category registries"

ThiloWitt avatar Apr 01 '19 08:04 ThiloWitt

I'll first need to verify that this is properly considered at all places, e.g. quick navigation form type and other form types.

Guite avatar Apr 01 '19 20:04 Guite

Example for overriding the method:

public function hasMultipleSelection($objectType = '', $registry = '')
{
    if ('person' === $objectType) {
        return 'MySpecial' === $registry;
    }

    return parent::hasMultipleSelection($objectType, $registry);
}

This would enable the multi selection for the MySpecial registry, but not for other ones registered for the same entity (person).

But it won't work at all places yet, because there are some more changes required in the form classes and/or the categories form type in the core.

Guite avatar May 27 '19 08:05 Guite