I have a wallpaper DataObject.
I'm managing my wallpaper in a DataObjectManager that is integrated in a category page.
A wallpaper has fields like title, image, rating and tags. The tags should be entered as String but stored in a seperate table....
So "blue, sky, nature" in a Textfield should be written into a table with a record for each tag like this
"blue"
"sky"
"nature"
First I had the tags as a simple string (sperated by ","). But as you start filtering wallpapers by tags and try to find other wallpapers with similar tags (like: show wallpapers that have the most amount of common tags) you want to use a second table and use sql's join queries.
So now I have a getCMSFields_forPopup() for my Picture Dataobject, that is being called, when adding/editing a picture to/of a gallery.
In this popup I have a nested DataObjectManager for the tags and it's not comfortable. Each time I add or edit a tag, the popup content is being replaced by the content of the add/edit dialog of the tags and when I'm finished adding/editing I can't get back to the original popup view. I can only press the general popup close and so the whole popup dissappears, although I didn't finish filling out the other fields (like choosing a title and other stuff) of the original popup view.
So either... is there a way to just close the inner DataObjectManager view instead of the whole popup or...
can I somehow have TextField for my tags where I can write something like "blue, sky, nature" but have a function that writes and reads those tags to/from other DataObjects that are bind by a has_many relationship ?
Here is a code excerpt:
<?php
class Wallpaper extends DataObject{
static $db = array('Name'=>'Text');
static $has_one = array('KategoriePage'=>'KategoriePage','WallpaperBild'=>'CustomImage');
static $has_many = array('PictureTags'=>'PictureTag');
public function getCMSFields_forPopup(){
return new FieldSet(
new ImageField('WallpaperBild','Das eigentliche Bild'),
new TextField('Name','Name des Bildes'),
new DataObjectManager($this,'PictureTags','PictureTag',PictureTag::$tabellen_namen,'getCMSFields_forPopup')
);
}
}
?>
<?php
class PictureTag extends DataObject{
static $db = array('Name'=>'Text');
static $has_one = array("Wallpaper"=>"Wallpaper");
static $tabellen_namen = array('Name'=>'Tag');
public function getCMSFields_forPopup(){
return new FieldSet(
new TextField('Name','Tag')
);
}
}
?>