I'm creating a few widgets for a project I'm working on and it seems widgets do not have access to any of the other classes from outside the widget. I've tried adding a has_one static for both image and SiteTree classes (see example below for image example) and I am getting the same error when I try and add the cms field: Fatal error: Call to a member function FormAction() on a non-object in /..../sapphire/forms/FormField.php on line 139
<?php
class AdBoxWidget extends Widget{
static $title = "";
static $cmsTitle = "Ad Box Widget";
static $description = "Ad Box widget. To add an image, Title and Link";
static $db = array(
"Title" => "Text",
"Link" => "Text",
"AdLinkText" => "Text"
);
static $defaults = array(
"Title" => 'Ad Title',
"Link" => 'http://',
"AdLinkText" => 'Click here for more info',
);
static $has_one = array(
'AdImage' => 'Image'
);
function getCMSFields(){
return new FieldList(
new TextField("Title", "Ad Title"),
new TextField("Link", "Ad Link"),
new TextField("AdLinkText", "Text for Link"),
new UploadField("AdImage", "Ad image")
);
}
function getAd(){
$output = new ArrayList();
$output->push(
new ArrayData(
array(
"Title" => $this->Title,
"Link" => $this->Link,
"AdLinkText" => $this->AdLinkText
)
)
);
return $output;
}
}