silverstripe / silverstripe-framework

Silverstripe Framework, the MVC framework that powers Silverstripe CMS
https://www.silverstripe.org
BSD 3-Clause "New" or "Revised" License
720 stars 822 forks source link

BUG: Readonly version of Dropdown field has a different validation rule #11042

Closed sunnysideup closed 6 months ago

sunnysideup commented 8 months ago

Affected Version

5

Description

When the code is like this, I can save it fine.

    public function getCMSFields()
    {
        $fields = parent::getCMSFields();

        return $fields;
    }

However, when the code is like this:

    public function getCMSFields()
    {
        $fields = parent::getCMSFields();

        $fields->addFieldsToTab(
            'Root.RelatedTo',
            [
                $fields->dataFieldByName('ClientID')->performDisabledTransformation(),
            ]
        );

        return $fields;
    }

I can not save the record:

image

emteknetnz commented 8 months ago

In the first example, is ClientID in the edit form and being POSTed when you save the record?

GuySartorelli commented 6 months ago

Please remove the call to addFieldsToTab() which at best is adding unnecessary confusion in your reproduction code.

sunnysideup commented 6 months ago

DONE.

GuySartorelli commented 6 months ago

You only removed it from one of the two examples. :p I assume also that you've tested it with the new example code?

Please also respond to https://github.com/silverstripe/silverstripe-framework/issues/11042#issuecomment-1803019062

sunnysideup commented 6 months ago

I will gather some more information and see if I can set up example.

sunnysideup commented 6 months ago

I am having a closer look at this, and I will close this ticket and create a new one. I am looking at the difference between SearchableDropdownTrait::setSource and DropdownField::setSource.