Update: Go to page 2 and look at the first post for the final code to do this.
I have created a ProfilePage.php page that has many Photo Sets.
I also created a PhotoSet.php object that has a Title and many Photos but only managed to have the Title Field in the Pop up.
I also created a Photo.php object that has a Caption and a Photo.
What I'm having trouble is have the ability to add multiple Photos on the Photo Set pop-up of Profile Page.
Is this even possible?
Here is the code for all 3 pages.
Again I want so that when I click on "Add Photo Set" on a Profile Page to also give me the ability to add multiple images to that Photo Set not just the Photo Set title.
ProfilePage.php
<?php
class ProfilePage extends Page {
static $has_many = array(
'PhotoSets' => 'PhotoSet'
);
function getCMSFields() {
$fields = parent::getCMSFields();
$photosetfield = new DataObjectManager(
$this,
'PhotoSets',
'PhotoSet',
array(
'PhotoSetTitle' => 'PhotoSetTitle'
),
'getCMSFields_forPopup'
);
$photosetfield->setAddTitle('Photo Set');
$fields->addFieldToTab('Root.Content.PhotoSets', $photosetfield);
return $fields;
}
}
class ProfilePage_Controller extends Page_Controller {}
?>
PhotoSet.php
<?php
class PhotoSet extends DataObject {
static $db = array(
'PhotoSetTitle' => 'Varchar(255)'
);
static $has_one = array(
'ProfilePage' => 'ProfilePage'
);
static $has_many = array(
'Photos' => 'Photo'
);
}
?>
Photo.php
<?php
class Photo extends DataObject {
static $db = array(
'PhotoCaption' => 'Varchar(255)'
);
static $has_one = array(
'Attachment' => 'File'
);
public function getCMSFields_forPopup() {
return new FieldSet(
new TextField('PhotoCaption'),
new FileIFrameField('Attachment')
);
}
}
?>