Call to undefined method Silverstripe GridfieldWhat's the best method for sanitizing user input with PHP?“Notice: Undefined variable”, “Notice: Undefined index”, and “Notice: Undefined offset” using PHPCall to undefined function curl_init().?Laravel/Ardent - on save(), error: Relationship method must return an object of type IlluminateSilverstripe: Member relation many many null, form front endCalling the default exceptionHandler equivalent in SilverStripe 4Can I have 2 gridfield components in an admin page in Silverstripe 4Silverstripe drag and drop reorderSilverStripe - Undefined Index on DataObject onBeforeWriteIn Silverstripe 4, a standard “Add” button of a GridField does nothing

Was the Lonely Mountain, where Smaug lived, a volcano?

What made the Ancient One do this in Endgame?

Will users know a CardView is clickable

How did the European Union reach the figure of 3% as a maximum allowed deficit?

Should I worry about having my credit pulled multiple times while car shopping?

Can a 40amp breaker be used safely and without issue with a 40amp device on 6AWG wire?

The title "Mord mit Aussicht" explained

Sakkāya-Ditthi and Self-View

How would Japanese people react to someone refusing to say “itadakimasu” for religious reasons?

Print the phrase "And she said, 'But that's his.'" using only the alphabet

Manager wants to hire me; HR does not. How to proceed?

How can religions without a hell discourage evil-doing?

How to test soql with For Update statement

Can I give my friend the sour dough "throw away" as a starter to their sourdough starter?

Bullying by school - Submitted PhD thesis but not allowed to proceed to viva until change to new supervisor

Can I appeal credit ding if ex-wife is responsible for paying mortgage?

Are athletes' college degrees discounted by employers and graduate school admissions?

Is it unethical to quit my job during company crisis?

Can Dive Down protect a creature against Pacifism?

What does the output current rating from an H-Bridge's datasheet really mean?

Why is Skinner so awkward in Hot Fuzz?

Leveling up and Getting Items!

Is fission/fusion to iron the most efficient way to convert mass to energy?

Is it possible to install Firefox on Ubuntu with no desktop enviroment?



Call to undefined method Silverstripe Gridfield


What's the best method for sanitizing user input with PHP?“Notice: Undefined variable”, “Notice: Undefined index”, and “Notice: Undefined offset” using PHPCall to undefined function curl_init().?Laravel/Ardent - on save(), error: Relationship method must return an object of type IlluminateSilverstripe: Member relation many many null, form front endCalling the default exceptionHandler equivalent in SilverStripe 4Can I have 2 gridfield components in an admin page in Silverstripe 4Silverstripe drag and drop reorderSilverStripe - Undefined Index on DataObject onBeforeWriteIn Silverstripe 4, a standard “Add” button of a GridField does nothing






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








2















I need to have additional fields on a extended file but there is an error occur.



This will add a gallery tab with GridField which will allow the user to add images.



Not sure what is missing since it is working on other projects.



[Emergency] Uncaught Error: Call to undefined method MyProjectExtensionsBlogPostExtension::BlogGalleryImages()



<?php 


namespace MyProjectExtensions;


use SilverStripeORMDataExtension;
use SilverStripeFormsFieldList;
use SilverStripeFormsTextField;
use SilverStripeFormsGridFieldGridField;
use SilverStripeFormsGridFieldGridFieldConfig_RelationEditor;
use SilverStripeFormsGridFieldGridFieldAddNewButton;
use SilverStripeFormsGridFieldGridFieldDetailForm;
use SilverStripeFormsGridFieldGridFieldEditButton;
use SilverStripeFormsGridFieldGridFieldDeleteAction;
use UndefinedOffsetSortableGridFieldFormsGridFieldSortableRows;
use SilverStripeViewRequirements;
use MyProjectModelBlogGalleryImage;

class BlogPostExtension extends DataExtension

private static $db = [
'SortOrder' => 'Int'
];

private static $has_many = [
"BlogGalleryImages" => BlogGalleryImage::class,
];

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

$fields->removeByName("SortOrder");
$options = $this->BlogGalleryImages();
$gridFieldConfig = GridFieldConfig::create()->addComponents(
new GridFieldAddNewButton('toolbar-header-right'),
new GridFieldToolbarHeader(),
new GridFieldSortableHeader(),
new GridFieldDataColumns(),
new GridFieldPaginator(80),
new GridFieldDetailForm(),
new GridFieldEditButton(),
new GridFieldDeleteAction()
);
$itemsTable = new GridField("BlogGalleryImages","Gallery Image",$options,$gridFieldConfig);
$fields->addFieldToTab('Root.Gallery',$itemsTable);






Here is the Dataobject file that supposed to be call on BlogPostExtension Class



<?php 

namespace MyProjectModel;

use SilverStripeAssetAdminFormsUploadField;
use SilverStripeAssetsImage;
use SilverStripeORMDataObject;

class BlogGalleryImage extends DataObject

private static $singular_name = 'Gallery Image';

private static $db = array(
'Title' => 'Varchar(256)',
'SortOrder' => 'Int'
);

private static $has_one = array(
'Image' => Image::class,
'BlogPosts' => BlogPost::class,
);

private static $owns = [
'Image',
];

private static $summary_fields = array(
'Thumbnail',
'Title'
);

private static $table_name = 'MyProject_BlogGallery';


private static $default_sort = "SortOrder ASC";

public function getCMSFields()
$fields = parent::getCMSFields();

$fields->removeByName("SortOrder");
$fields->removeByName("BlogPostID");
$fields->addFieldToTab("Root.Main", new TextField("Title","Title"));
$fields->addFieldToTab("Root.Main", $uploadfield = UploadField::create("Image","Image"));
$uploadfield->setFolderName("BlogGallery");

return $fields;


public function getThumbnail()
if ($icon = $this->Image())
return $icon->CMSThumbnail();
else
return '(No Image)';













share|improve this question




























    2















    I need to have additional fields on a extended file but there is an error occur.



    This will add a gallery tab with GridField which will allow the user to add images.



    Not sure what is missing since it is working on other projects.



    [Emergency] Uncaught Error: Call to undefined method MyProjectExtensionsBlogPostExtension::BlogGalleryImages()



    <?php 


    namespace MyProjectExtensions;


    use SilverStripeORMDataExtension;
    use SilverStripeFormsFieldList;
    use SilverStripeFormsTextField;
    use SilverStripeFormsGridFieldGridField;
    use SilverStripeFormsGridFieldGridFieldConfig_RelationEditor;
    use SilverStripeFormsGridFieldGridFieldAddNewButton;
    use SilverStripeFormsGridFieldGridFieldDetailForm;
    use SilverStripeFormsGridFieldGridFieldEditButton;
    use SilverStripeFormsGridFieldGridFieldDeleteAction;
    use UndefinedOffsetSortableGridFieldFormsGridFieldSortableRows;
    use SilverStripeViewRequirements;
    use MyProjectModelBlogGalleryImage;

    class BlogPostExtension extends DataExtension

    private static $db = [
    'SortOrder' => 'Int'
    ];

    private static $has_many = [
    "BlogGalleryImages" => BlogGalleryImage::class,
    ];

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

    $fields->removeByName("SortOrder");
    $options = $this->BlogGalleryImages();
    $gridFieldConfig = GridFieldConfig::create()->addComponents(
    new GridFieldAddNewButton('toolbar-header-right'),
    new GridFieldToolbarHeader(),
    new GridFieldSortableHeader(),
    new GridFieldDataColumns(),
    new GridFieldPaginator(80),
    new GridFieldDetailForm(),
    new GridFieldEditButton(),
    new GridFieldDeleteAction()
    );
    $itemsTable = new GridField("BlogGalleryImages","Gallery Image",$options,$gridFieldConfig);
    $fields->addFieldToTab('Root.Gallery',$itemsTable);






    Here is the Dataobject file that supposed to be call on BlogPostExtension Class



    <?php 

    namespace MyProjectModel;

    use SilverStripeAssetAdminFormsUploadField;
    use SilverStripeAssetsImage;
    use SilverStripeORMDataObject;

    class BlogGalleryImage extends DataObject

    private static $singular_name = 'Gallery Image';

    private static $db = array(
    'Title' => 'Varchar(256)',
    'SortOrder' => 'Int'
    );

    private static $has_one = array(
    'Image' => Image::class,
    'BlogPosts' => BlogPost::class,
    );

    private static $owns = [
    'Image',
    ];

    private static $summary_fields = array(
    'Thumbnail',
    'Title'
    );

    private static $table_name = 'MyProject_BlogGallery';


    private static $default_sort = "SortOrder ASC";

    public function getCMSFields()
    $fields = parent::getCMSFields();

    $fields->removeByName("SortOrder");
    $fields->removeByName("BlogPostID");
    $fields->addFieldToTab("Root.Main", new TextField("Title","Title"));
    $fields->addFieldToTab("Root.Main", $uploadfield = UploadField::create("Image","Image"));
    $uploadfield->setFolderName("BlogGallery");

    return $fields;


    public function getThumbnail()
    if ($icon = $this->Image())
    return $icon->CMSThumbnail();
    else
    return '(No Image)';













    share|improve this question
























      2












      2








      2








      I need to have additional fields on a extended file but there is an error occur.



      This will add a gallery tab with GridField which will allow the user to add images.



      Not sure what is missing since it is working on other projects.



      [Emergency] Uncaught Error: Call to undefined method MyProjectExtensionsBlogPostExtension::BlogGalleryImages()



      <?php 


      namespace MyProjectExtensions;


      use SilverStripeORMDataExtension;
      use SilverStripeFormsFieldList;
      use SilverStripeFormsTextField;
      use SilverStripeFormsGridFieldGridField;
      use SilverStripeFormsGridFieldGridFieldConfig_RelationEditor;
      use SilverStripeFormsGridFieldGridFieldAddNewButton;
      use SilverStripeFormsGridFieldGridFieldDetailForm;
      use SilverStripeFormsGridFieldGridFieldEditButton;
      use SilverStripeFormsGridFieldGridFieldDeleteAction;
      use UndefinedOffsetSortableGridFieldFormsGridFieldSortableRows;
      use SilverStripeViewRequirements;
      use MyProjectModelBlogGalleryImage;

      class BlogPostExtension extends DataExtension

      private static $db = [
      'SortOrder' => 'Int'
      ];

      private static $has_many = [
      "BlogGalleryImages" => BlogGalleryImage::class,
      ];

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

      $fields->removeByName("SortOrder");
      $options = $this->BlogGalleryImages();
      $gridFieldConfig = GridFieldConfig::create()->addComponents(
      new GridFieldAddNewButton('toolbar-header-right'),
      new GridFieldToolbarHeader(),
      new GridFieldSortableHeader(),
      new GridFieldDataColumns(),
      new GridFieldPaginator(80),
      new GridFieldDetailForm(),
      new GridFieldEditButton(),
      new GridFieldDeleteAction()
      );
      $itemsTable = new GridField("BlogGalleryImages","Gallery Image",$options,$gridFieldConfig);
      $fields->addFieldToTab('Root.Gallery',$itemsTable);






      Here is the Dataobject file that supposed to be call on BlogPostExtension Class



      <?php 

      namespace MyProjectModel;

      use SilverStripeAssetAdminFormsUploadField;
      use SilverStripeAssetsImage;
      use SilverStripeORMDataObject;

      class BlogGalleryImage extends DataObject

      private static $singular_name = 'Gallery Image';

      private static $db = array(
      'Title' => 'Varchar(256)',
      'SortOrder' => 'Int'
      );

      private static $has_one = array(
      'Image' => Image::class,
      'BlogPosts' => BlogPost::class,
      );

      private static $owns = [
      'Image',
      ];

      private static $summary_fields = array(
      'Thumbnail',
      'Title'
      );

      private static $table_name = 'MyProject_BlogGallery';


      private static $default_sort = "SortOrder ASC";

      public function getCMSFields()
      $fields = parent::getCMSFields();

      $fields->removeByName("SortOrder");
      $fields->removeByName("BlogPostID");
      $fields->addFieldToTab("Root.Main", new TextField("Title","Title"));
      $fields->addFieldToTab("Root.Main", $uploadfield = UploadField::create("Image","Image"));
      $uploadfield->setFolderName("BlogGallery");

      return $fields;


      public function getThumbnail()
      if ($icon = $this->Image())
      return $icon->CMSThumbnail();
      else
      return '(No Image)';













      share|improve this question














      I need to have additional fields on a extended file but there is an error occur.



      This will add a gallery tab with GridField which will allow the user to add images.



      Not sure what is missing since it is working on other projects.



      [Emergency] Uncaught Error: Call to undefined method MyProjectExtensionsBlogPostExtension::BlogGalleryImages()



      <?php 


      namespace MyProjectExtensions;


      use SilverStripeORMDataExtension;
      use SilverStripeFormsFieldList;
      use SilverStripeFormsTextField;
      use SilverStripeFormsGridFieldGridField;
      use SilverStripeFormsGridFieldGridFieldConfig_RelationEditor;
      use SilverStripeFormsGridFieldGridFieldAddNewButton;
      use SilverStripeFormsGridFieldGridFieldDetailForm;
      use SilverStripeFormsGridFieldGridFieldEditButton;
      use SilverStripeFormsGridFieldGridFieldDeleteAction;
      use UndefinedOffsetSortableGridFieldFormsGridFieldSortableRows;
      use SilverStripeViewRequirements;
      use MyProjectModelBlogGalleryImage;

      class BlogPostExtension extends DataExtension

      private static $db = [
      'SortOrder' => 'Int'
      ];

      private static $has_many = [
      "BlogGalleryImages" => BlogGalleryImage::class,
      ];

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

      $fields->removeByName("SortOrder");
      $options = $this->BlogGalleryImages();
      $gridFieldConfig = GridFieldConfig::create()->addComponents(
      new GridFieldAddNewButton('toolbar-header-right'),
      new GridFieldToolbarHeader(),
      new GridFieldSortableHeader(),
      new GridFieldDataColumns(),
      new GridFieldPaginator(80),
      new GridFieldDetailForm(),
      new GridFieldEditButton(),
      new GridFieldDeleteAction()
      );
      $itemsTable = new GridField("BlogGalleryImages","Gallery Image",$options,$gridFieldConfig);
      $fields->addFieldToTab('Root.Gallery',$itemsTable);






      Here is the Dataobject file that supposed to be call on BlogPostExtension Class



      <?php 

      namespace MyProjectModel;

      use SilverStripeAssetAdminFormsUploadField;
      use SilverStripeAssetsImage;
      use SilverStripeORMDataObject;

      class BlogGalleryImage extends DataObject

      private static $singular_name = 'Gallery Image';

      private static $db = array(
      'Title' => 'Varchar(256)',
      'SortOrder' => 'Int'
      );

      private static $has_one = array(
      'Image' => Image::class,
      'BlogPosts' => BlogPost::class,
      );

      private static $owns = [
      'Image',
      ];

      private static $summary_fields = array(
      'Thumbnail',
      'Title'
      );

      private static $table_name = 'MyProject_BlogGallery';


      private static $default_sort = "SortOrder ASC";

      public function getCMSFields()
      $fields = parent::getCMSFields();

      $fields->removeByName("SortOrder");
      $fields->removeByName("BlogPostID");
      $fields->addFieldToTab("Root.Main", new TextField("Title","Title"));
      $fields->addFieldToTab("Root.Main", $uploadfield = UploadField::create("Image","Image"));
      $uploadfield->setFolderName("BlogGallery");

      return $fields;


      public function getThumbnail()
      if ($icon = $this->Image())
      return $icon->CMSThumbnail();
      else
      return '(No Image)';










      php silverstripe-4






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 25 at 2:27









      Capitan KamoteCapitan Kamote

      455




      455






















          1 Answer
          1






          active

          oldest

          votes


















          1














          You're calling an instance method on your extension which doesn't exist:



          $options = $this->BlogGalleryImages();


          This is actually a magic method which represents your has_many relationship "BlogGalleryImages" - this is scaffolded by DataObject. You need to refer to the extension's owner in order to access it:



          $options = $this->getOwner()->BlogGalleryImages();





          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55330540%2fcall-to-undefined-method-silverstripe-gridfield%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            You're calling an instance method on your extension which doesn't exist:



            $options = $this->BlogGalleryImages();


            This is actually a magic method which represents your has_many relationship "BlogGalleryImages" - this is scaffolded by DataObject. You need to refer to the extension's owner in order to access it:



            $options = $this->getOwner()->BlogGalleryImages();





            share|improve this answer



























              1














              You're calling an instance method on your extension which doesn't exist:



              $options = $this->BlogGalleryImages();


              This is actually a magic method which represents your has_many relationship "BlogGalleryImages" - this is scaffolded by DataObject. You need to refer to the extension's owner in order to access it:



              $options = $this->getOwner()->BlogGalleryImages();





              share|improve this answer

























                1












                1








                1







                You're calling an instance method on your extension which doesn't exist:



                $options = $this->BlogGalleryImages();


                This is actually a magic method which represents your has_many relationship "BlogGalleryImages" - this is scaffolded by DataObject. You need to refer to the extension's owner in order to access it:



                $options = $this->getOwner()->BlogGalleryImages();





                share|improve this answer













                You're calling an instance method on your extension which doesn't exist:



                $options = $this->BlogGalleryImages();


                This is actually a magic method which represents your has_many relationship "BlogGalleryImages" - this is scaffolded by DataObject. You need to refer to the extension's owner in order to access it:



                $options = $this->getOwner()->BlogGalleryImages();






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 25 at 2:45









                Robbie AverillRobbie Averill

                21.5k74177




                21.5k74177





























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55330540%2fcall-to-undefined-method-silverstripe-gridfield%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                    Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

                    Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript