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

inherit dataobject ( or something)


Go to End


17 Posts   6985 Views

Avatar
swaiba

Forum Moderator, 1899 Posts

24 February 2011 at 10:33pm

Are you still using HasOneDataObjectManager & HasManyDataObjectManager?
Or are the screen prints now from mainly scaffolded FieldSet?

Because what you are asking for is what I would expect when ModelAdmin does the work, but the problem you describe sounds like you are building them yourself...

Avatar
Stefdv

Community Member, 110 Posts

25 February 2011 at 4:53am

Swaiba,

Yes, i am using HasOneDataObjectManager & HasManyDataObjectManager...What i understand from your question is that i'm handling this the wrong way??

---------------------------------------------------


//Stamboom
		$fields->addFieldToTab("Root.Stamboom", new HasOneDataObjectManager(
								  $this,
								  'Stamboom',
								  'Stamboom'
								  )
							   );
		//Showresultaten
		$fields->addFieldToTab("Root.Showresultaten", new HasManyDataObjectManager(
								  $this,
								  'Showresultaten',
								  'Showresultaat'
								  )
							   );

------------------------------------------------------------------------------------------------------------------------

Avatar
swaiba

Forum Moderator, 1899 Posts

25 February 2011 at 6:09am

Edited: 25/02/2011 6:10am

Well, I wouldn't say it was the wrong way, just the DOM way ;-)

Firstly DOM functions are not silverstripe - if they don't work then the only place to ask for help in the section UncleCheese moderates - DataObjectManager. For this reason I do not use it - instead I stick close to the core.

Secondly the silverstripe API HasManyComplexTableField & HasOneComplexTableField (which DOM builds on top) are there to use and I have occasionally added one of these - BUT with your dataobjuects set up correctly - then these are scaffolded for you - why write the code again yourself?

I recommend you drop each one of your getCMSFields function from the data objects and see how ModelAdmin scaffolds it all, then change what you want changed...

Avatar
Stefdv

Community Member, 110 Posts

25 February 2011 at 8:41am

Swaiba,

Thank u so much !!!

This totally changes the way i work with SS. I think i finnaly got it...(well...there will be questions in the future ;) )
Now i understand what you mean with adding fields and pushing them to other tabs.

That Modeladmin thing is great...i used everything at once ( DOM and ModelAdmin ), when in fact the modeladmin does it right.

TX

Avatar
swaiba

Forum Moderator, 1899 Posts

25 February 2011 at 10:45pm

you are very welcome - ModelAdmin was when I started to like silverstripe alot - since I often build web applications the CRUD of data is very important and important to be able to prototype and get something running as soon as possible - write less code get more functionality - thank you silverstripe!

Avatar
Stefdv

Community Member, 110 Posts

26 February 2011 at 12:40am

Swaiba,

Is it possible to show all datobjects in modeladmin at once instead of per 10 ? ( I mean like default )

Avatar
swaiba

Forum Moderator, 1899 Posts

26 February 2011 at 12:44am

Edited: 26/02/2011 12:49am

sure check this out... http://open.silverstripe.org/ticket/5665
..it has a couple of modeladmin improvements in it, including what you ask for :)

oh and if you want to change the number of results put "$this->setPageSize(15);" in your init (at the end of the dataobject init) - I don't advise putting 999999 into it to show all as this can lead a rather odd looking screen for large numbers of results

a.u.b.

Avatar
Stefdv

Community Member, 110 Posts

26 February 2011 at 12:59am

Swaiba,

I'm sorry you had to stumble on me :(

I'm not sure what you mean with the DataObject Init...Do i have to make a function Init, in my DataObject ?