Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Customising the CMS /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Error while adding fields to the CMS


Go to End


2 Posts   1003 Views

Avatar
CodeTrix

Community Member, 1 Post

15 January 2015 at 4:48pm

Hi

Thank you for any help in advance

We have a an error while adding fields to the CMS. This was working fine a few months ago as I added a few fields successfully.

The two new fields are 'CaseStudy' and 'CaseStudyYT'. There is not much more I can add, but the code and error should make it clear.

Below is the script that's in /mysite/code, and attached is the error

Thanks
CodeTrix

<?php
class HomePage extends Page {

	private static $db = array(
        'Eligible'    => 'HTMLText',
	'CaseStudy'   => 'HTMLText',
	'CaseStudyYT' => 'HTMLText',
        'SEA' 		  => 'HTMLText',
        'Savings'     => 'HTMLText',
        'TalkToUs'    => 'HTMLText',
        'Carousel1'   => 'HTMLText',
        'Carousel2'   => 'HTMLText',
        'Carousel3'   => 'HTMLText',
        'Carousel4'   => 'HTMLText'        
	);
  
  static $has_one = array(
      'Polaroid1Picture' => 'Image',
      'Polaroid2Picture' => 'Image',
      'Polaroid3Picture' => 'Image',
      'Polaroid4Picture' => 'Image',
      'Polaroid5Picture' => 'Image',
      'Polaroid6Picture' => 'Image',
      'QandAPicture' => 'Image',
      'EligiblePicture' => 'Image',
      'ContactPicture' => 'Image'
  );
  
  public function getCMSFields() {
      $fields = parent::getCMSFields();

      $fields->removeFieldFromTab('Root.Main', 'Content');
      
      $fields->addFieldToTab('Root.Panels', new HtmlEditorField('Eligible'));
      $fields->addFieldToTab('Root.Panels', new HtmlEditorField('CaseStudy'));
      $fields->addFieldToTab('Root.Panels', new TextField('CaseStudyYT'));
      $fields->addFieldToTab('Root.Panels', new HtmlEditorField('SEA'));
      $fields->addFieldToTab('Root.Panels', new HtmlEditorField('Savings'));
      $fields->addFieldToTab('Root.Panels', new HtmlEditorField('TalkToUs'));

      $fields->addFieldToTab('Root.Carousels', new HtmlEditorField('Carousel1'));
      $fields->addFieldToTab('Root.Carousels', new HtmlEditorField('Carousel2'));
      $fields->addFieldToTab('Root.Carousels', new HtmlEditorField('Carousel3'));
      $fields->addFieldToTab('Root.Carousels', new HtmlEditorField('Carousel4'));
      
      $fields->addFieldToTab('Root.Upload', $uploadField = new UploadField(
        $name = 'Polaroid1Picture',
        $title = 'Upload picture for the First Polaroid'
      ));
      $fields->addFieldToTab('Root.Upload', $uploadField = new UploadField(
        $name = 'Polaroid2Picture',
        $title = 'Upload picture for the Second Polaroid'
      ));
      $fields->addFieldToTab('Root.Upload', $uploadField = new UploadField(
        $name = 'Polaroid3Picture',
        $title = 'Upload picture for the Third Polaroid'
      ));
      $fields->addFieldToTab('Root.Upload', $uploadField = new UploadField(
        $name = 'Polaroid4Picture',
        $title = 'Upload picture for the Fourth Polaroid'
      ));
      $fields->addFieldToTab('Root.Upload', $uploadField = new UploadField(
        $name = 'Polaroid5Picture',
        $title = 'Upload picture for the Fifth Polaroid'
      ));
      $fields->addFieldToTab('Root.Upload', $uploadField = new UploadField(
        $name = 'Polaroid6Picture',
        $title = 'Upload picture for the Sixth Polaroid'
      ));
      $fields->addFieldToTab('Root.Upload', $uploadField = new UploadField(
        $name = 'QandAPicture',
        $title = 'Upload picture for the Q&A Panel'
      ));
      $fields->addFieldToTab('Root.Upload', $uploadField = new UploadField(
        $name = 'EligiblePicture',
        $title = 'Upload picture for the Eligible Panel'
      ));
      $fields->addFieldToTab('Root.Upload', $uploadField = new UploadField(
        $name = 'ContactPicture',
        $title = 'Upload picture for the Contact Panel'
      ));
      return $fields;
  }

}
class HomePage_Controller extends Page_Controller {

	/**
	 * An array of actions that can be accessed via a request. Each array element should be an action name, and the
	 * permissions or conditions required to allow the user to access it.
	 *
	 * <code>
	 * array (
	 *     'action', // anyone can access this action
	 *     'action' => true, // same as above
	 *     'action' => 'ADMIN', // you must have ADMIN permissions to access this action
	 *     'action' => '->checkAction' // you can only access this action if $this->checkAction() returns true
	 * );
	 * </code>
	 *
	 * @var array
	 */
	private static $allowed_actions = array (
	);

	public function init() {
		parent::init();
		// You can include any CSS or JS required by your project here.
		// See: http://doc.silverstripe.org/framework/en/reference/requirements
	}

}

Attached Files
Avatar
Devlin

Community Member, 344 Posts

15 January 2015 at 9:20pm