Hi,
I am getting an error when trying to create a GridField.
GET http://localhost/sspass/admin/pages/edit/show/36
500 Error at line 675 of /home/USERNAME/www/sspass/framework/core/Object.php
ERROR [User Error]: Uncaught Exception: Object->__call(): the method 'sspassgroups' does not exist on 'SspassPage'
IN GET /sspass/admin/pages/edit/show/36
Line 675 in /home/USERNAME/www/sspass/framework/core/Object.php
I have 2 DataObject
SspassAccount.php
----------------------------------------------
class SspassAccount extends DataObject{
public static $db = array(
'Name' => 'Varchar(255)',
'Content' => 'HTMLText'
);
public static $has_one = array(
'SspassPage' => 'SspassPage',
'SspassGroup' => 'SspassGroup'
);
public static $singular_name = 'SspassAccount';
public static $plural_name = 'SspassAccounts';
public function getCMSFields() {
parent::getCMSFields();
$fields = new FieldList(
new TextField( 'Name' , 'Account Name') ,
new TextareaField( 'Content' , 'Content')
);
return $fields;
}
}
SspassGroup.php
----------------------------------------------
class SspassGroup extends DataObject{
public static $db = array(
'Name' => 'Varchar(255)'
);
public static $has_meny = array(
'SspassAccounts' => 'SspassAccount'
);
public static $has_one = array(
'SspassPage' => 'SspassPage'
);
static $singular_name = 'SspassGroup';
static $plural_name = 'SspassGroups';
public function getCMSFields() {
parent::getCMSFields();
$fields = new FieldList(
new TextField( 'Name' , 'Name')
);
return $fields;
}
}
and the page
SspassPage.php
----------------------------------------------
class SspassPage extends Page{
public static $db = array(
);
public static $has_one = array(
);
public static $has_meny = array(
'SspassAccounts' => 'SspassAccount',
'SspassGroups' => 'SspassGroup'
);
public function getCMSFields(){
$fields = parent::getCMSFields();
$config = GridFieldConfig_RelationEditor::create();
$config->getComponentByType('GridFieldDataColumns')->setDisplayFields(array(
'Name' => 'Name'
));
// Create a gridfield to hold the student relationship
$groupsField = new GridField(
'SspassGroups',
'SspassGroups',
$this->SspassGroups(), // <--------- ERROR [User Error]: Uncaught Exception: Object->__call(): the method 'sspassgroups' does not exist on 'SspassPage'
$config
);
$fields->addFieldToTab( 'Root.Groups', $groupsField);
return $fields;
}
}
The bussiness logic:
SspassPage should have 2 tabs, one for adding accounts and one for edding groups, one groupe has meny accounts
Am I missing something?