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.

All other Modules /

Discuss all other Modules here.

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

Extending LeftAndMain Help


Go to End


1664 Views

Avatar
Gringo

Community Member, 1 Post

30 November 2009 at 1:20am

Hi Guys,

I've used the forums for a while for information and this is the first time I've had to post, I'm attempting to write a new LeftAndMain module for managing some data.

What I'm trying to get tested and working is a complextablefield in a new tab in the right panel, I'm wanting to use it to manage data from a dataobject. I'm coming across the following error and after an hour or so of browsing I have no idea what I'm doing wrong.

Fatal error: Call to a member function FormAction() on a non-object in H:\www\ijacca.co.uk\sapphire\forms\FormField.php on line 88

Code

<?php

class JobsAdmin extends LeftAndMain {
static $url_segment = 'jobs';
static $menu_title = 'Jobs Administration';

static $has_many = array (

"Jobs"=>"Job",
"Categorys"=>"Category",
"RSSImports"=>"RSSImport"

);

/*
public static $managed_models = array(
'Jobs',
'Category',
'RSSImports'
);*/

function init() {
parent::init();
}

function showForm() {

/*$fields = parent::getCMSFields();

$jobs = new HasManyComplexTableField($this, 'Jobs', 'Jobs', array("Title"=>"Job Title","Location"=>"Job Location","Approved"=>"Approved for viewing"));

$fields->addFieldToTab("Root.Jobs",$jobs);

return $fields;*/
return new TabSet(
$name = "TheTabSetName",
new Tab(
$title='Tab one',
new HeaderField("A header"),
new LiteralField("Lipsum","Lorem ipsum dolor sit amet enim.")
),
new Tab(
$title='Tab two',
new HeaderField("A second header"),
new LiteralField("Lipsum","Ipsum dolor sit amet enim."),
new ComplexTableField(
$controller = $this,
$name = "Jobs",
$sourceClass = "Job",
$fieldList = array(
"Title"=>"Job Title",
"Location"=>"Job Location",
"Approved"=>"Approved for viewing"
),
$callThisFunctionForPopupFields = "getCMSFields_forPopup",
$sourceFilter = "",
$sourceSort = ""
)
)
);

}

}
?>

--------------------------------------------------------

<?php

class Job extends DataObject {

static $db = array (
'RecuiterID'=>'Int',
'Title'=>'Text',
'Salery'=>'Int',
'Sector'=>'Int',
'Location'=>'Text',
'JobType'=>'Int',
'Description'=>'HTMLText',
'Approved'=>'Boolean'
);

function getCMSFields_forPopup() {
return new FieldSet(
new TextField('Title', 'Job Title'),
new TextareaField('Description', 'Job Description'),
new CheckboxField("Approved", "Job Approved")
);
}

}

?>

----------------------------------------------------

I was going to use a has_many type until I noticed that the way I wanted things done I would have no has_one, so I though the complextablefield would be the way forward.

Can anyone shed any light on my stupidity?

Thanks in advance,

Graham