21294 Posts in 5734 Topics by 2602 members
General Questions
SilverStripe Forums » General Questions » Having issues with CheckboxSetField - Call to a member function Name() on a non-object
General questions about getting started with SilverStripe that don't fit in any of the categories above.
Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 1587 Views |
-
Having issues with CheckboxSetField - Call to a member function Name() on a non-object

20 June 2009 at 12:06pm Last edited: 20 June 2009 2:38pm
I'm trying to create a CheckboxSetField but I keep on getting the following error message when the CMS Popup appears:
"Fatal error: Call to a member function Name() on a non-object in" ... "\sapphire\forms\FieldSet.php on line 395"When I remove the checkbox field from the popup it works fine - so I'm sure its isolated to just the CheckboxSetField. I have looked over the Silverstripe documentation and I can't see what I am doing wrong. Below is the code that I am using - Any ideas? (Just in case - I'm using WAMP to develop this site and have updated to the latest stable version - SilverStripe-v2.3.2)
ProductDetail.php
<?php
class ProductDetail extends DataObject {
...
static $many_many = array(
'FilterColor' => 'FilterColor',
...
);function getCMSFields_forPopup() {
$FilterColorObj = DataObject::get('FilterColor');
$FilterColorMap = $FilterColorObj ? $FilterColorObj->toDropdownMap('ID','Title') : array();
$FilterColorList = new CheckboxSetField(
'FilterColor',
'FilterColor',
$FilterColorMap
);
$fields->push( $filterColorList );
...
return $fields;
}
}?>
FilterColor.php
<?php
class FilterColor extends DataObject {
static $db = array(
'Title' => 'Varchar',
'Hex' => 'Varchar'
);
public static $belongs_many_many = array(
'ProductDetail' => 'ProductDetail',
);
function getCMSFields_forPopup() {
$fields = new FieldSet();
$fields->push( new TextField( 'Title', 'Colour' ) );
$fields->push( new TextField( 'Hex', 'Hex', '', 6 ) );
return $fields;
}
}
?> -
Re: Having issues with CheckboxSetField - Call to a member function Name() on a non-object

20 June 2009 at 1:08pm
In ProductDetail you've got a field called "Color", that should be "FilterColor" I believe?
-
Re: Having issues with CheckboxSetField - Call to a member function Name() on a non-object

20 June 2009 at 2:40pm Last edited: 20 June 2009 2:41pm
Thanks for the pointer but even after the changes (I've updated the code above) I'm still getting the same error message:
"Fatal error: Call to a member function Name() on a non-object in ...\sapphire\forms\FieldSet.php on line 395" -
Re: Having issues with CheckboxSetField - Call to a member function Name() on a non-object

21 June 2009 at 1:10pm
Figured out....
$FilterColorList = new CheckboxSetField(
'FilterColor',
'FilterColor',
$FilterColorMap
);
$fields->push( $filterColorList );The variable is $FilterColorList and i have tried to push $filterColorList instead (stupid case sensitivity - I can't believe I didn't spot this to begin with.
-
Re: Having issues with CheckboxSetField - Call to a member function Name() on a non-object

21 June 2009 at 5:14pm
Completely missed that one too!
| 1587 Views | ||
|
Page:
1
|
Go to Top |


