SilverStripe CMS: how to make a connection in form (select list) to another DataObject/Page in has_one fashion

StackOverflow https://stackoverflow.com/questions/9380971

문제

Let say I have a Event Page Object with should be connected to one Trainer. How Can I add to Event object a select list with All Trainers (Trainers are also a Page).

I Know hot to add a connection type by $has_one property, but I dont know how to popuate select with trainers objects.

도움이 되었습니까?

해결책

$trainers = DataObject::get('Trainer');
$fields->addFieldToTab('Root.Content.Main', new DropdownField('TrainerID', 'Trainer', $trainers->map() );
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top