1
votes

I'm about to extend Silverstripe Module. But I can't figure out what is missing on my simple code.

I need some suggestion to solve what is missing.

namespace {

    use SilverStripe\ORM\DataExtension;
    use SilverStripe\Forms\FieldList;
    use SilverStripe\Forms\TextField;

    class BlogPostExtension extends DataExtension {

        private static $db = [
            'Title' => 'Varchar'
        ];

        public function updateCMSFields(FieldList $fields) {
            // Add fields here

            $fields->addFieldToTab("Root.Gallery", new TextField("Title","Title"));

        }

    }

}

This what I've added on app.yml. I also doing /dev/build?flush=all. But still nothing works.

SilverStripe\Blog\BlogPost:
  extensions:
    - Project\Extensions\BlogPostExtension
1
As BlogPost is a subclass of SiteTree, it already has a Title field. You cannot add another field with this name to it. Try renaming it to "GalleryTitle" or something unique. - wmk
Thank you for your response. I already renamed the field but still not working. - Capitan Kamote

1 Answers

1
votes

as wmk pointed out - Title is already part of the fields in the FieldList. If you rename the field to a different name. For example "GalleryTitle" and run dev/build you should have more success.

-- Peter