Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Data Model Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

SiteTree TreeDropdownField always readonly


Go to End


827 Views

Avatar
KPBR

Community Member, 4 Posts

30 March 2017 at 7:40pm

Hello,
I have two (separate) DataObject subclasses, each containing a $has_one like this:

private static $has_one = array(
	'PageLink'=>'SiteTree',
	'Picture'=>'Image'
);

and in getCMSFields,
TreeDropdownField::create('PageLinkID', 'Optional page to link to', 'SiteTree'),

but in the CMS, it always appears as readonly (i.e. just the name of what it's linking to, and viewing source shows "treedropdownfield_readonly"). Even when I explicitly make it not readonly afterwards.
What's really weird is that if I change $has_one to
private static $has_one = array(
	'PageLink'=>'SiteTree',
	'Dummy'=>'SiteTree',
	'Picture'=>'Image'
);

it is no longer readonly (but creating a TreeDropdownField for Dummy is readonly). Any ideas what the problem could be? This is driving me partially insane.

On a secondary note, having

'Picture.SetWidth(100)'=>'Picture',
in my $summary_fields doesn't make it display, but using a custom method does. Is this related?

All help is greatly appreciated.