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

Automatic Refresh of has_many in ModelAdmin (HasManyComplexTableField?)


Go to End


1333 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',
	);
}