Created
October 20, 2014 03:57
-
-
Save hailwood/92ce49dab81d45653282 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class CarouselImage extends DataObject { | |
public static $db=array( | |
'Title'=>'Varchar', | |
'SortOrder'=>'Int' | |
); | |
public static $default_sort='SortOrder'; | |
private static $has_one = array( | |
'Image' => 'Image' | |
); | |
public function getCMSFields() { | |
$uploadField = new UploadField('Image'); | |
$uploadField->setFolderName('Uploads/Carousel'); | |
$fields = new FieldList(array(new TextField('Title'),$uploadField)); | |
return $fields; | |
} | |
} | |
class CarouselImageAdmin extends ModelAdmin { | |
private static $managed_models = array('CarouselImage'); | |
private static $url_segment = 'carouselimages'; | |
private static $menu_title = 'Carousel Images'; | |
public function getEditForm($id = null, $fields = null) { | |
/** @var CMSform $form */ | |
$form = parent::getEditForm($id, $fields); | |
$gridField = new GridFieldSortableRows('SortOrder'); | |
$form->Fields()->items[0]->config->addComponent($gridField); | |
return $form; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment