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.

General Questions

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

[Solved]What's wrong with my code?


Reply

7 Posts   765 Views

Avatar
zcm211

28 April 2009 at 1:50pm (Last edited: 28 April 2009 8:20pm), Community Member, 18 Posts

Table YoutubePage: renamed to _obsolete_YoutubePage
Table YoutubePage_versions: renamed to _obsolete_YoutubePage_versions
Table YoutubePage_Live: renamed to _obsolete_YoutubePage_Live

<?php
class YoutubePage extends Page
{
   static $db = array(
      #'YoutubeLink' => 'Text'
   );
   static $has_one = array(
   );
}

class YoutubePage_Controller extends Page_Controller
{
   function getCMSFields() {
      $fields = parent::getCMSFields();      
      $fields->addFieldToTab('Root.Content.Main', new TextField('YoutubeLink'), 'YoutubeLink');
      return $fields;
   }
}
?>

Avatar
Double-A-Ron

28 April 2009 at 3:15pm Community Member, 604 Posts

#'YoutubeLink' => 'Text'

That's a parse error (#). Why is it there?

And if you want help, it's a good idea to explain:

1. What you are trying to do
2. What error you are getting

Cheers
Aaron

Avatar
zcm211

28 April 2009 at 3:40pm Community Member, 18 Posts

sorry, I want to add some costom fields, but there is no effect.

Avatar
Double-A-Ron

28 April 2009 at 3:52pm Community Member, 604 Posts

So now you're alright then? You see the problem?

Avatar
zcm211

28 April 2009 at 5:14pm Community Member, 18 Posts

no,it is not alright. the page's Main tag still do not display the field I want.

Avatar
Double-A-Ron

29 April 2009 at 12:07am Community Member, 604 Posts

Then why did you set the subject to [solved]?

You need to be more detailed with your questions. I have pointed out the error in the code you posted.

Cheers
Aaron

Avatar
zcm211

29 April 2009 at 12:32pm Community Member, 18 Posts

After I posted my second topics, I found I add the mehtod to the wrong class, so the error is fixed. Thanks for your attending.