Created
July 19, 2015 16:01
-
-
Save gordonbanderson/cfb433d2078b5d7bd2cb 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 Grocery extends DataObject { | |
private static $db = array( | |
'Name' => 'Varchar(255)', | |
'Price' => 'Int' | |
); | |
private static $belongs_many_many = array( | |
'GroceryPages' => 'GroceryPage' | |
); | |
} |
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 GroceryAdmin extends ModelAdmin { | |
private static $managed_models = array('Grocery'); | |
private static $url_segment = 'groceries'; | |
private static $menu_title = 'Groceries'; | |
private static $menu_icon = '/your/path/to/groceryicon.png'; | |
} |
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 GroceryPage extends Page { | |
private static $many_many = array( | |
'Groceries' => 'Grocery' | |
); | |
function getCMSFields() { | |
$fields = parent::getCMSFields(); | |
$gridConfig = GridFieldConfig_RelationEditor::create(); | |
$gridConfig->getComponentByType( 'GridFieldAddExistingAutocompleter' )->setSearchFields( array( 'Name' ) ); | |
$gridConfig->getComponentByType( 'GridFieldPaginator' )->setItemsPerPage( 100 ); | |
$gridField = new GridField( "Groceries", "List of Groceries:", $this->Groceries(), $gridConfig ); | |
$fields->addFieldToTab( "Root.Groceries", $gridField ); | |
return $fields; | |
} | |
} | |
class GroceryPage_Controller extends Page_Controller { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment