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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Data Model Questions /

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

Automatic Refresh of has_many in ModelAdmin (HasManyComplexTableField?)


Go to End


1141 Views

Avatar
swaiba

Forum Moderator, 1899 Posts

14 December 2010 at 1:31am

Suppose I have the code below... when I add 'ObjectWithOne' to 'ObjectWithMany' using ModelAdmin the new item doesn't appear in the this list. I need to hit search again, then re-select the 'ObjectWithMany' i created the 'ObjectWithOne' for. This also is an issue when I edit one of the items - it doesn't update the list upon closing the popup...

...is there anything someone can help me with to get this fixed please?

<?php

class HasManyAdmin extends ModelAdmin
{
	static $managed_models = array(
		'ObjectWithMany',
	);

	static $url_segment = 'hasmanyadmin';
	static $menu_title = 'HasManyAdmin';
}

class ObjectWithMany extends DataObject
{
	static $db = array(
		'Name' => 'Text',
	);

	static $has_many = array(
		'ObjectWithOne' => 'ObjectWithOne',
	);
}


class ObjectWithOne extends DataObject
{
	static $db = array(
		'Name' => 'Text',
	);

	static $has_one = array(
		'ObjectWithMany' => 'ObjectWithMany',
	);
}