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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Form Questions /

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

Call to a member function FormAction() on a non-object


Go to End


1638 Views

Avatar
Stefanovic72

Community Member, 3 Posts

21 December 2014 at 10:16am

Hello,

I run into a problem and I have no idea hat the cause can be. Can anyone point me in the right direction?
Any help is very much appreciated!

This is the error I get:

Call to a member function FormAction() on a non-objectin /home/sites/development/000_SILVERSTRIPE/www/3_1_8/framework/forms/FormField.php on line 157, referer: http://www.bestmeat4u.hst3.nl/admin/bm-settings/

This is the code:

First SettingsAdmin.php

class SettingsAdmin extends LeftAndMain {

    private static $model_importers = array();
    static $url_segment = 'bm-settings';    
    static $menu_title = 'BM Instellingen';  
    static $menu_icon = 'bm-settings/images/icons/flexslider_icon.png';

    function getEditForm() {
        $fields = new FieldList(
            new TabSet(
                $name = "Root",
                new Tab(
                    $title='Verkoop',
                    new TabSet(
                        $name='Verkoop',
                        new Tab(
                            $title='Verkoopitems'
                        )
                    )
                )
            )
        );
        $conf=GridFieldConfig_RecordEditor::create(10);
        $emaildefault = DataObject::get('EmailDefault', '', 'SortOrder ASC');
        $grid= new GridField('EmailContent', 'EmailContent', $emaildefault, $conf);
        $fields->addFieldToTab('Root.Verkoop.Verkoop.Verkoopitems', $grid);

        return $fields;
    }
}

And EmailDeafult.php:

<?php
class EmailDefault extends DataObject {
    private static $db = array(
        'Name' => 'Varchar',
        'Description' => 'Varchar',
        'SortOrder'   => 'Int'
    );

    public function getCMSFields() {
        $fields = parent::getCMSFields();
        return $fields;
    }
}

It goes wrong in this line:
$fields->addFieldToTab('Root.Verkoop.Verkoop.Verkoopitems', $grid);

When I replace this line with this I don't get thet error and the headerfield is added to the tab.
$fields->addFieldToTab('Root.Verkoop.Verkoop.Verkoopitems', new HeaderField('Article categories', 2));

So my conclusion, it goes wrong at the moment the grid is added to the tab but why? Creating the grid doesn't give an error.