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

DataObject Question


Go to End


2 Posts   1913 Views

Avatar
ttyl

Community Member, 114 Posts

18 November 2009 at 8:09am

Edited: 18/11/2009 8:10am

I've gotten some strange behavior trying to put a ManyManyComplexTableField into a DataObject. When I put in the following code and try to create a new entry I just get a blank box and my PHP logs say "Call to a member function MyUnits() on a non-object in /Applications/MAMP/htdocs/ss_clean/sapphire/forms/HasManyComplexTableField.php" - but when I try to edit an existing record I get the table I want but nothing gets saved when I updated even though it says it went through.

class Person extends DataObject {

static $db = array(
'FirstName' => 'Text',
'LastName' => 'Text',
'Role' => 'Text',
'Email' => 'Text'
);

static $has_one = array(
'HeadShot' => 'Image',
);

static $many_many = array (
'MyUnits' => 'Unit'
);

function getCMSFields_forPopup() {
$fields = new FieldSet();

$fields->push( new TextField( 'FirstName', 'First Name' ) );
$fields->push( new TextField( 'LastName', 'Last Name' ) );
$fields->push( new TextField( 'Email' ) );

$fields->push(new DropdownField('Role', 'Role', array(
'Alumni' => 'Alumni',
'Faculty' => 'Faculty',
'Staff' => 'Staff',
'Student' =>'Student'
)), 'Content'
);

$fields->push(new ImageField('HeadShot'));

$fields->push(new ManyManyComplexTableField(
$this,
'MyUnits',
'Unit',
array('Name' => 'Unit Name')
));

return $fields;
}

---

so when I take out the "push->(new ManyMany..." I can create a new record, but when I put it back in it only shows on edit - but nothing gets saved. I'm not sure if I'm explaining this clearly as I'm honestly confused...

Avatar
ttyl

Community Member, 114 Posts

18 November 2009 at 8:27am

realized this was the wrong forum - moved question to here: http://silverstripe.org/data-model-questions/show/273608?showPost=273608