7911 Posts in 1354 Topics by 930 members
DataObjectManager Module
SilverStripe Forums » DataObjectManager Module » Show variable instead ClassID in BO
Discuss the DataObjectManager module, and the related ImageGallery module.
Moderators: martimiz, UncleCheese, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 527 Views |
-
Show variable instead ClassID in BO

11 January 2011 at 1:50am
Hi guys i have a class:
class Marca extends DataObject {
static $db = array(
'Nomemar' => 'Varchar(255)'
);static $has_many = array(
'Modelos' => 'Modelo'
);static $belongs_many_many = array(
'Produtos' => 'Produto'
);static $searchable_fields = array(
'Nomemar'
);static $summary_fields = array(
'Nomemar' => 'Nome'
);function getCMSFields()
{
$fields = parent::getCMSFields();
$fields->push(new TextField('Nomemar','Nome Marca')
);return $fields;
}function forTemplate() { return $this->Nomemar; }
}and:
class Modelo extends DataObject {
static $db = array(
'Nomemod' => 'Varchar(255)'
);static $has_one = array(
'Marcas' => 'Marca'
);/*
static $belongs_many_many = array(
'Produtos' =>'Produto'
);*/static $summary_fields = array(
'Nomemod' => 'Nome Modelo',
'Nomemar'=>'NomeMARCAS'
);function getCMSFields()
{
$fields = parent::getCMSFields();$fields ->push(new TextField('Nomemod','Nome Modelo'));
$modulesMarcas = new HasOneDataObjectManager(
$this,
'Marcas',
'Marca',
array(
'Nomemar' => 'Nome'
),
'getCMSFields'
);$fields->removeFieldFromTab('Root', 'Main'); // replace the tab with MMDOM tab
$fields->push( $modulesMarcas );
return $fields;}
function forTemplate() { return $this->Nomemod; }
}and another class Product
where i have
$managermod = new ManyManyDataObjectManager(
$this, // Controller
'Modelos', // Source name
'Modelo', // Source class
array('Nomemod' => 'Nome Modelo',
'MarcasID' => 'Nome Marcas'
),
'getCMSFields' );
$f->removeFieldFromTab('Root', 'Modelos'); // replace the tab with MMDOM tab
$f->addFieldToTab('Root.Modelos', $managermod);so i want have 'MarcasNomemar' => 'Nome Marcas' instead 'MarcasID' => 'Nome Marcas' in my backoffice
sugestions...
-
Re: Show variable instead ClassID in BO

11 January 2011 at 4:03am
Just use a custom getter..
public function getMarcasNomemar() {
if($m = $this->Marcas()) {
return $m->Nomemar;
}
return false;
}array (
'MarcasNomemar' => 'Nome Marcas'
); -
Re: Show variable instead ClassID in BO

11 January 2011 at 5:04am
dont worked...
so... this code:
public function getMarcasNomemar() {
if($m = $this->Marcas()) {
return $m->Nomemar;
}
return false;
}i have put in... class Marca?
and, this
array (
'MarcasNomemar' => 'Nome Marcas'
);go to "ManyManyDataObjectManager" right?
-
Re: Show variable instead ClassID in BO

11 January 2011 at 6:34am
No, that function belongs in Modelo.. the class being managed by the DOM..
--------------------
SilverStripe tips, tutorials, screencasts and more: http://www.leftandmain.com -
Re: Show variable instead ClassID in BO

11 January 2011 at 6:54am
oh yeah...
Awesome... thank's UncleCheese! Already worked....
-
Re: Show variable instead ClassID in BO

12 January 2011 at 4:43am Last edited: 12 January 2011 4:43am
i' have the same for class Produto how i do one see that the relations are difrent ...
Are the same way?
| 527 Views | ||
|
Page:
1
|
Go to Top |

