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   811 Views

Avatar
zcm211

Community Member, 18 Posts

28 April 2009 at 1:50pm

Edited: 28/04/2009 8:20pm

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

Community Member, 604 Posts

28 April 2009 at 3:15pm

#'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

Community Member, 18 Posts

28 April 2009 at 3:40pm

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

Avatar
Double-A-Ron

Community Member, 604 Posts

28 April 2009 at 3:52pm

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

Avatar
zcm211

Community Member, 18 Posts

28 April 2009 at 5:14pm

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

Avatar
Double-A-Ron

Community Member, 604 Posts

29 April 2009 at 12:07am

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

Community Member, 18 Posts

29 April 2009 at 12:32pm

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.