Big THANKS to you UncleCheese. After a little trial and error and guidance from you (tried my best not to ask you for more help) I finally figured it out.
Here is the final code for the basics of what I've been trying to do. This currently works but if there is something messy that I should probably clean up please advise. I'm a designer not a developer and Silverstripe has been a great experience. I hope this helps others out there :)
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'
)
);
$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'
);
public function getCMSFields() {
return new FieldSet(
new TextField('PhotoSetTitle'),
new FileDataObjectManager(
$this,
'Photos',
'Photo',
'Attachment',
array(
'PhotoCaption' => 'PhotoCaption'
)
)
);
}
}
?>
Photo.php
<?php
class Photo extends DataObject {
static $db = array(
'PhotoCaption' => 'Varchar(255)'
);
static $has_one = array(
'Attachment' => 'File',
'PhotoSet' => 'PhotoSet'
);
public function getCMSFields() {
return new FieldSet(
new TextField('PhotoCaption'),
new FileIFrameField('Attachment')
);
}
}
?>
ProfilePage.ss
$Content
<% if PhotoSets %>
<% control PhotoSets %>
$PhotoSetTitle
<% control Photos %>
$Attachment
$PhotoCaption
<% end_control %>
<% end_control %>
<% end_if %>
$Form
$PageComments