silverstripe / silverstripe-admin

Silverstripe Admin Component
BSD 3-Clause "New" or "Revised" License
25 stars 91 forks source link

TreeDropdownField::setDisableFunction() has no visual or functional affect #1688

Open UndefinedOffset opened 4 months ago

UndefinedOffset commented 4 months ago

Module version(s) affected

2.1.17

Description

TreeDropdownField::setDisableFunction() has no visual or functionality affects in at least 2.1.17 (but likely in 2.0 as well), where as in 1.13.22 the options are faded and not clickable. In 1.13.22 this appears like the below: dropdown-example

Note in 1.13 this will properly allow selection at any depth.

How to reproduce

To Reproduce create a Test Page type for example:

class TestPage extends Page {}

Then seed a mix of page types in the page tree including at least one TestPage at any depth and add a TreeDropdownField to another object that has a disable function that simply checks to see if the incoming page is an instance of TestPage.

TreeDropdownField::create('TargetPageID', 'Target Page', SiteTree::class)
    ->setDisableFunction(function (SiteTree $page) {
        return !is_a($page, TestPage::class);
    }),

Possible Solution

No response

Additional Context

No response

Validations