3070 Posts in 869 Topics by 651 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 825 Views |
-
[resolved] many_many dont save ? i need help

14 August 2010 at 10:45am Last edited: 18 August 2010 3:48pm
I will try to explain as best as possible. The problem is as follows
It is assumed that you should create a relationship many to many the problem is that it seems not to keep the relationship between DataObject and the page just kept in the DataObject.
This should not be longer than another site should not be alone show me items that classname with some ID
but apparently this is not so the code is as follows.
File Iconografia.php
Class Iconografia extends DataObject {
public static $db = array();
public static $has_one = array(
'Imagen' => 'Image'
);
static $belongs_many_many = array(
'Objs' => __CLASS__
);/* For DataObjectManage */
/*public function getImagen(){
$image = $this->Imagen();
return $image->CroppedImage(50,50);
}public function getName() {
$image = $this->Imagen();
return $image->Name;
}*/public function getCMSFields_forPopup() {
$fields = new FieldSet();
$ImgField = new ImageField('Imagen','Icono');
$ImgField->setFolderName('Iconografia');
$fields->push($ImgField);
return $fields;
}
}File SolucionesHolder.php
class SolucionesHolder extends Page {
static $db = array ();static $has_one = array (
'ImgHeader' => 'Image'
);static $many_many = array(
'MyIconografia' => 'Iconografia'
);
public function getCMSFields() {
$fields = parent::getCMSFields();
$MyIco = new ManyManyComplexTableField(
$this,
'MyIconografia',
'Iconografia',
Array('Imagen'=>'Icono','Name'=>'Nombre'),
'getCMSFields_forPopup'
);
$ImgField = new ImageField ( 'ImgHeader', 'Imagen de cabezera' );
$ImgField->setFolderName ( 'Categorias' );
$fields->addFieldToTab("Root.Content.Iconografia",$MyIco);
$fields->addFieldToTab("Root.Content.Main", $ImgField );
return $fields;
}
}My SiteTree is Like this
|-Site
|-Solutions => PageClass
\
*|-- DataCenter => SolucionesHolder => many_many (Iconografia)
*|-- Voice => SolucionesHolder => many_many (Iconografia)
*\
**|-- Product 1 => SolucionPage => => many_many (Iconografia)
**|-- Product 2 => SolucionPage => => many_many (Iconografia)
**|-- Product 3 => SolucionPage => => many_many (Iconografia)
**|-- Product 4 => SolucionPage => => many_many (Iconografia)
....I hope to be clear in advance thank you very much
-
Re: [resolved] many_many dont save ? i need help

18 August 2010 at 3:47pm Last edited: 18 August 2010 3:50pm
well actually this code was my mistake to select each item was not selecting duuu .. hehe thanks anyway ..
Maybe you can take the code example to those who have no very clear how works many_many relationship
| 825 Views | ||
|
Page:
1
|
Go to Top |
