I've tried looking for a solution, and while seeing one or two others with similar issues, I've not seen a solution. I'm using Model Admin for object management, and I'm trying to use ImageDataObjectManager to allow for a has_many relationship to images. When I add images in the DOM when returning to the normal DOM view (i.e. the popup closes) the screen doesn't refresh and show the images. Using the search function in ModelAdmin to see the new item, clicking on it gets a non-stop loading 'swirl' animation and an error along the lines of:
Warning: "strpos() expects parameter 1 to be string, array given" at line 268 of /opt/webapps/shawn/silverstripe2.4/sapphire/core/ViewableData.php
Here is my class for the main object:
ArtCatalogItem.php
<?php
class ArtCatalogItem extends DataObject {
static $db = array(
"ObjectName" => "Varchar(255)",
"AccessionNumber" => "Varchar(255)",
"ArtistMaker" => "Varchar(255)",
"DateOfObject" => "Date",
"Designer" => "Varchar(255)",
"Country" => "Varchar(255)",
"State" => "Varchar(255)",
"City" => "Varchar(255)",
"Techniques" => "Varchar(255)",
"Materials" => "Varchar(255)",
"Colors" => "Varchar(255)",
"StylesTypePattern" => "Varchar(255)",
"Size" => "Varchar(255)",
"Description" => "HTMLText",
"Source" => "Varchar(255)",
"Association" => "Enum('Gift,Loan,Purchase', 'Gift')",
"DateReceived" => "Date",
"DurationOfLoan" => "Varchar(255)",
"Collector" => "Varchar(255)",
"DateCollected" => "Date",
"Condition" => "Enum('Excellent,Good,Fair,Poor,Explain', 'Good')",
"ConditionExplanation" => "HTMLText",
"Location" => "Varchar(255)",
"Value" => "Varchar(255)",
"Remarks" => "HTMLText",
"Correspondence" => "Varchar(255)",
"CatalogReferences" => "Varchar(255)",
"EnteredBy" => "Varchar(255)",
"EnteredDate" => "Date"
);
static $has_many = array(
"Images" => "ArtCatalogImage"
);
static $belongs_many_many = array(
'Collections' => 'ArtCollectionPage'
);
static $summary_fields = array(
'AccessionNumber' => 'Accession Number',
'ObjectName' => 'Object Name'
);
function getCMSFields() {
$f = parent::getCMSFields();
// Code to make collections tab populate from CMS created pages
$collections = DataObject::get('ArtCollectionPage');
$f->addFieldToTab("Root.Collections", new CheckboxSetField('Collections', 'Collections', $collections));
// Code to set up the image manager
$manager = new ImageDataObjectManager(
$this,
'Images',
'ArtCatalogImage',
'ArtImage',
array('Title'),
'getCMSFields_forPopup'
);
$f->addFieldToTab("Root.Images", $manager);
return $f;
}
}
?>
And here is my helper class to get details on the image and do a has_one for the image:
ArtCatalogImage.php
<?php
class ArtCatalogImage extends DataObject {
static $db = array(
'Title' => 'Varchar(255)',
'Caption' => 'HTMLText'
);
static $has_one = array(
"ArtImage" => "Image",
"ArtCatalogItem" => "ArtCatalogItem"
);
public function getCMSFields_forPopup() {
return new FieldSet(
new TextField('Title'),
new SimpleTinyMCEField('Caption')
);
}
}
?>
Silverstripe 2.4.5 and I checked DOM out of GIT yesterday (4/13/11).
Any ideas on why this isn't working? It does seem to be adding things to the database properly, there are records for the images the ArtCatalogItem and the ArtCatalogImage and all the relationships appear to be in place.
Any help will be greatly appreciated, thanks!