I am attempting to build a module for the agile carousel (www.agilecarousel.com). This is also the first module I will have written for SilverStripe so I hope I'm not biting off more than I can chew. I started off reading the tutorial that guides you through the randomlinks module, but comments and forum posts lead me to believe that some of these methods are outdated.
I have started to put together classes, and am using ModelAdmin for adding to the CMS (see attached). I'm hoping to gain some understanding of data relationships and using them to make the CMS interface powerful from this thread.
My basic idea for this was to allow for creating slides in the CMS (for now enter html code with text/image). Allow for creating carousels by assigning a title(i.e. home page carousel), and finally letting the user select which slides are included on each carousel. At the moment I am getting an error when I click the create carousel button. "Fatal error: Call to a member function dataFields() on a non-object in C:\website\cs\sapphire\forms\Form.php on line 821"
I'm assuming this is because of a bad relationship. Here is my code so far:
AgileCarouselAdmin.php:
class AgileCarouselAdmin extends ModelAdmin {
public static $managed_models = array(
'Carousel',
'Slide'
);
static $url_segment = 'agilecarousel';
static $menu_title = 'Agile Carousel';
}
Carousel.php:
<?php
class Carousel extends DataObject {
static $db = array (
'Title' => 'Varchar'
);
static $has_many = array(
'Slides' => 'Slide'
);
function getCMSFields_forPopup() {
$fields = new FieldSet();
$fields->push( new TextField('Title') );
return $fields;
}
function getCMSfields() {
$fields = parent::getCMSFields();
$tablefield = new HasOneComplexTableField (
$this,
'Slides',
'Slide',
array(
'Title' => 'Title'
),
'getCMSFields_forPopup'
);
}
}
Slide.php:
<?php
class Slide extends DataObject {
static $db = array(
'Title' => 'Varchar',
'Code' => 'HTMLText'
);
}
Expertise, tutorials, references--any help is really appreciated!