Skip to content

Instantly share code, notes, and snippets.

@trentsnippets
Last active December 18, 2015 15:09
Show Gist options
  • Save trentsnippets/5802432 to your computer and use it in GitHub Desktop.
Save trentsnippets/5802432 to your computer and use it in GitHub Desktop.
Add New Input Fields to the CMS in SIlver Stripe
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