I have a custom widget called "CustomLinksWidget.php". In this widget I would like to give the ability to enter links and I need to use GridField. I'll type below the essential part of the code:
(CustomLinkWidget.php)
----------------------------------------------------------
private static $has_many = array(
'CustomLinks' => 'CustomLink'
);
public function getCMSFields(){
new GridField(
'CustomLinks',
'CustomLinks',
$this->CustomLinks(),
new GridFieldConfig_RelationEditor()
)
);
----------------------------------------------------------
CustomLink.php
----------------------------------------------------------
class CustomLink extends DataObject {
private static $db = array(
'Title' => 'Varchar(100)',
'URL' => 'Varchar(120)'
);
private static $has_one = array(
'CustomLinksWidget' => 'CustomLinksWidget'
);
public function getCMSFields() {
$fields = FieldList::create(
TextField::create('Title'),
TextField::create('URL')
);
return $fields;
}
}
----------------------------------------------------------
This return the following error:
Fatal error: Call to a member function FormAction() on null in D:\webserver\htdocs\clients\sarah\ncl\framework\forms\FormField.php on line 277