Login | Forgot password | Register
What is OpenID?
OpenID is an Internet-wide identity system that allows you to sign in to many websites with a single account.
With OpenID, your ID becomes a URL (e.g. http://username.myopenid.com/). You can get a free OpenID for example from myopenid.com.
For more information visit the official OpenID site.
Archive
SilverStripe Forums » Archive » Error: 'ParentID' appears twice
Our old forums are still available as a read-only archive.
|
Page:
1
|
Go to End | |
| Author | Topic: Error: 'ParentID' appears twice | 423 Views |
-
Error: 'ParentID' appears twice

16 May 2008 at 11:31am Last edited: 16 May 2008 12:03pm
Hi,
I'm trying to create a new dataobject called Category. You can have categories and sub-categories so I'm trying to code it so that a Category object can have another Category object as it's parent (has_one) or it can have multiple "Category" objects (has_many).
I thought this would be quite simple but I can't work out how to get around this error (see title of post). This is what I have so far:
class Category extends DataObject {
static $db = array(
'Name' => 'Text',
"Type" => "Enum('Business, Event, Community', 'Business')"
);
static $default_sort = "Name";static $has_one = array(
'Parent' => 'Category'
);
static $has_many = array(
'Children' => 'Category'
);function getCMSFields_forPopup() {
$fields = new FieldSet();
$fields->push( new TextField( 'Name' ) );
$fields->push( new DropdownField("ParentID", "Parent Category", array()));
$fields->push( new DropdownField("Type", "Type",
array(
'Business' => 'Business',
'Event' => 'Event',
'Community' => 'Community'
)
));
return $fields;
}
}I can see that it's not happy with the field I'm trying to create where you select the parent Category (or leave empty if it's a top-level category). How do I do this?? Are there any examples I can look at in one of the modules? I looked at the Post object in the Forum module but it's slightly different.
Thanks.
| 423 Views | ||
|
Page:
1
|
Go to Top |
Currently Online: motly, Thomas B. Nielsen
Welcome to our latest member: fearofbuttons

