Hi everyone,
for a project I have set up a nice project catalog with the help of the DataObjectsAsPage-Module. Everything works beautifully with SS3. Each project can have multiple categories and multiple images attached. This is also all working great. Images and categories can be defined in separate tabs of the project admin area.
However my customer now wants to add a photographer to each image and I am struggling somewhat on how to add an extra field to the image uploadField. I figured I need a class that extends Image or DataExtension and adds a table to the database. I defined this extended class in my project page as $many_many relation. I can add images but the extra field doesn't show.
I've tried something like, trying to adapt the doc on UploadFileds:
class ExtendedImage extends DataExtension {
static $db = array(
'Photographer' => 'Varchar',
);
static $has_one = array(
'Image' => 'Image'
);
function getCustomFields() {
$fields = new FieldList();
$fields->push(new TextField('Photographer', 'Fotograf'));
return $fields;
}
}
class Project extends DataObjectAsPage
{
[...]
static $many_many = array(
'ExtendedImages' => 'ExtendedImage',
'Categories' => 'Category'
);
public function getCMSFields() {
$fields = parent::getCMSFields();
[...]
$fields->addFieldToTab("Root.Images", $uploadField->setFileEditFields('getCustomFields'););
return $fields;
But I get an internal server error. This must be fairly simple. I'm just not seeing it. All I really need is an additional Textfield in the UploadField of the image Class. I'd be very grateful for any hint on this.
Sam