Last active
December 18, 2015 15:09
-
-
Save trentsnippets/5802432 to your computer and use it in GitHub Desktop.
Add New Input Fields to the CMS in SIlver Stripe
This file contains hidden or 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
class HomePage extends Page | |
{ | |
//Add static db array. This controls new databse fields added to this page type. | |
//These new columns will auto migrate to the db when running dev/build "flush=1" from the browser | |
static $db = array( | |
'HomeHeroTitle' => 'Varchar(100)', | |
'HomeHeroContent' => 'HTMLVarchar(1000)' | |
); | |
//Add Cms Fields | |
public function getCMSFields(){ | |
$fields = parent::getCMSFields(); | |
$fields->addFieldToTab('Root.Main', new TextField('HomeHeroTitle', 'Home Hero Title'), 'Content'); | |
$fields->addFieldToTab('Root.Main', new HTMLEditorField('HomeHeroContent', 'Home Hero Content'), 'Content'); | |
//Remove Standard Wysiwyg | |
$fields->removeFieldFromTab('Root.Main', 'Content'); | |
//return fields to CMS | |
return $fields; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment