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.

Customising the CMS /

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

[Solved] Adding field to CMS tab - SilverStripe 2.4.0


Go to End
Reply


8 Posts   2506 Views

Avatar
NARKOZ

Community Member, 25 Posts

6 July 2010 at 3:00am

Edited: 07/07/2010 5:18am

Hi. I was trying to add special field like this:

	public static $db = array(
		'VideoURL' => 'Text'
	);

   function getCMSFields() {
      $fields = parent::getCMSFields();
 
      $fields->addFieldToTab('Root.Content.Main', new DateField('VideoURL'), 'Content');
 
      return $fields;
   }

but this gave me no result (I don't see field in CMS). I'm using SilverStripe 2.4.0

Avatar
PeterNL

Community Member, 9 Posts

6 July 2010 at 5:38am

Did you flushed the database, with www.mysite.com/dev/build
????

Avatar
NARKOZ

Community Member, 25 Posts

6 July 2010 at 5:41am

Of course I did. It created necessasy records.

Avatar
Juanitou

Community Member, 323 Posts

6 July 2010 at 6:13am

Hi!

How do you expect to store a Text field in the database by using a DateField field in the CMS?

Avatar
NARKOZ

Community Member, 25 Posts

6 July 2010 at 6:58am

Oh, sorry. Anyway it doesn't work.

Avatar
NARKOZ

Community Member, 25 Posts

7 July 2010 at 3:38am

Edited: 07/07/2010 3:39am

Here: http://pastie.org/1032801 is full code of VideoPage.php

Avatar
Juanitou

Community Member, 323 Posts

7 July 2010 at 4:10am

The function getCMSFields() should be in the model (VideoPage class), not in the controller.

Avatar
NARKOZ

Community Member, 25 Posts

7 July 2010 at 5:18am

Thanks. Stupid mistake.
Solved.