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

TreeMultiSelectField has null value #195

Open
mlewis-everley opened this issue Mar 11, 2020 · 0 comments
Open

TreeMultiSelectField has null value #195

mlewis-everley opened this issue Mar 11, 2020 · 0 comments
Labels

Comments

@mlewis-everley
Copy link
Contributor

I have noticed this for a while and tried to trace the problem (with no luck).

If I am using a TreeMultiSelectField (in getCMSFields) then the value is not set in EditHandler.

The only way I can force this to happen is to overwrite EditHandler::getRecordEditFields() like so:

    private function getRecordEditingFields(DataObject $record)
    {
        $tempForm = Form::create(
            $this,
            'TempEditForm',
            $record->getCMSFields(),
            FieldList::create()
        );

        $tempForm->loadDataFrom($record);
        $fields = $tempForm->Fields();

        $fields = $this->filterRecordEditingFields($fields, $record->ID);

        // Relation field of type TreeMultiSelectField has to have its value forcefully set to a comma
        // seperated srting
        $fields['Categories']->setValue(implode(",", $record->Categories()->column('ID')));

        return $fields;
    }

The only way I can think to change this is maybe look for fields that are instances of TreeMultiSelectField and forcefully set their value?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants