Open JoshuaCarter opened 5 years ago
I had a got at replicating this and didn't manage to. The Treedropdown field seems to be working fine for me.
Could you provide some more replications steps?
@maxime-rainville Thanks for taking a look. I've added some details (and updated my fix snippet) if you can give that a look. I'm very interested to know if/where your own observations have differed from my own. Perhaps there is something unique to our project, but it's not obvious to me at this point.
Cheers.
https://github.com/silverstripe/silverstripe-admin/blob/46ce1a49e3e2e430c5712f8e850c8629c068f6bd/client/src/components/TreeDropdownField/TreeDropdownField.js#L654-L695
This surfaces as the TreeDropdownField appearing to have no value on initial load in the CMS.
Looking at the code snippet above,
this.props.value
comes through as a string ID, and is then given to the Select component without further alterations (assumingmulti
is false). But as perlabelKey
andvalueKey
, the Select component expectsvalue
to be an array.Currently working around this via:
To summarise:
The frontend logic (TreeDropdownField.js) expects to get/give its
value
as an array like:But the backend logic (TreeDropdownField.php) expects to get/give its
value
as a simple ID.Thus my workaround is to convert between these formats.
Edit 1: Updated code to what's now being used on our end. Edit 2: Added field usage code and summary.