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.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Create a HasOneComplexTable or HasMany in Dataobject?


Go to End


6 Posts   1330 Views

Avatar
Dr0gaz

Community Member, 37 Posts

30 December 2010 at 1:09am

Hi, everyone...

i've got a question it's possible create a HasOneComplexTable in "Class Products extends DataObject" for example ...
its possible make relationship for other classes?

Sorry guys i'am a newbie...
and sorry my english...

thanks all

Avatar
UncleCheese

Forum Moderator, 4102 Posts

30 December 2010 at 3:45am

Sounds like you want a nested DataObjectManager?

http://www.leftandmain.com/silverstripe-screencasts/2010/08/23/nested-dataobjectmanager-a-dom-in-a-dom/

--------------------
SilverStripe tips, tutorials, screencasts and more: http://www.leftandmain.com

Avatar
Dr0gaz

Community Member, 37 Posts

30 December 2010 at 4:06am

yeah.... i' follow these tuts... but i' newbie and try... try... to achieve... so i be a pacient... ehehe and try... try... try...

great job unclecheese...

Thanks!!

Avatar
Dr0gaz

Community Member, 37 Posts

30 December 2010 at 5:18am

The code is right?

<?php
class Fabricante extends DataObject {
static $db = array(
'Nomefab' => 'Varchar(255)',
);

static $has_many = array(
'Produtos'=>'Produto'
);

static $searchable_fields = array(
'Nomefab'
);

static $summary_fields = array(
'Nomefab' => 'Nome Fabricante'
);

function getCMSFields(){

return new FieldSet(

new TextField('Nomefab','Nome Fabricante')

);

$managerpro = new ManyManyComplexTableField(
$this,
'Produtos',
'Produto',
array('Nome'=>'Nome'),
'getCMSFields_forPopup' );

//$f->removeFieldFromTab('Root', 'Fabricantes'); //
$f->addFieldToTab('Root.Fabricantes', $managerpro);

}

}
?>

Avatar
UncleCheese

Forum Moderator, 4102 Posts

30 December 2010 at 5:38am

Since you're in the DataObjectManager forum, I have to recommend that you change "ManyManyComplexTableField" to "ManyManyDataObjectManager" :)

Avatar
Dr0gaz

Community Member, 37 Posts

30 December 2010 at 11:53pm

yes... that's worked!!
wonderful.... but i have other problem... in myCrm...

the interface appears unconfigured and dataobject gives errors... not save for example....