Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: setReadonly does not work on CheckboxField #3007

Open
2 tasks done
sunnysideup opened this issue Sep 18, 2024 · 0 comments
Open
2 tasks done

BUG: setReadonly does not work on CheckboxField #3007

sunnysideup opened this issue Sep 18, 2024 · 0 comments

Comments

@sunnysideup
Copy link
Contributor

Module version(s) affected

5.2

Description

setReadonly(true) does not work on a checkboxField (and potentially others).

How to reproduce

Take a DataObject with a bunch of fields and then run:

        foreach (array_keys($this->config()->get('db')) as $readonlyField) {
            $formFieldTmp = $fields->dataFieldByName($readonlyField);
            if ($formFieldTmp) {
                        $formFieldTmp->setDescription('set to readonly');
                        $fields->replaceField($readonlyField, $formFieldTmp->setReadonly(true));
            }
        }

and for each field asses it it acts and looks and feels as readonly

Possible Solution

implement properly across of fields OR, use performReadonlyTransformation instead.

Additional Context

What would be nice if you could simply write:

$fields->dataFieldByName('MyBooleanField')->setReadonly(true)

and it would actually change, rather than having to replace the original field.

Validations

  • Check that there isn't already an issue that reports the same bug
  • Double check that your reproduction steps work in a fresh installation of silverstripe/installer (with any code examples you've provided)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant