<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Forum posts to 'Site Builders'</title>
		<link>http://www.silverstripe.com/site-builders-forum/</link>
		

		
		<item>
			<title>Error: 'ParentID' appears twice</title>
			<link>http://www.silverstripe.com/site-builders-forum/show/73956</link>
			<description>Hi,&lt;br /&gt;&lt;br /&gt;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 &quot;Category&quot; objects (has_many).&lt;br /&gt;&lt;br /&gt;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:&lt;br /&gt;&lt;br /&gt;[code]&lt;br /&gt;class Category extends DataObject { &lt;br /&gt;	static $db = array(&lt;br /&gt;		'Name' =&amp;gt; 'Text',		&lt;br /&gt;		&quot;Type&quot; =&amp;gt; &quot;Enum('Business, Event, Community', 'Business')&quot;		&lt;br /&gt;  );&lt;br /&gt;	static $default_sort = &quot;Name&quot;;&lt;br /&gt;&lt;br /&gt;  static $has_one = array(	&lt;br /&gt;    'Parent' =&amp;gt; 'Category'&lt;br /&gt;  );&lt;br /&gt;	static $has_many = array(&lt;br /&gt;		'Children' =&amp;gt; 'Category'&lt;br /&gt;	);&lt;br /&gt; &lt;br /&gt;	function getCMSFields_forPopup() {&lt;br /&gt;		$fields = new FieldSet();&lt;br /&gt;		$fields-&amp;gt;push( new TextField( 'Name' ) );		&lt;br /&gt;		$fields-&amp;gt;push( new DropdownField(&quot;ParentID&quot;, &quot;Parent Category&quot;, array()));		&lt;br /&gt;		$fields-&amp;gt;push( new DropdownField(&quot;Type&quot;, &quot;Type&quot;, &lt;br /&gt;			array(&lt;br /&gt;				'Business' =&amp;gt; 'Business',&lt;br /&gt;				'Event' =&amp;gt; 'Event',&lt;br /&gt;				'Community' =&amp;gt; 'Community'&lt;br /&gt;			)&lt;br /&gt;		));		&lt;br /&gt;		return $fields;&lt;br /&gt;	} &lt;br /&gt;}&lt;br /&gt;[/code]&lt;br /&gt;&lt;br /&gt;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.&lt;br /&gt;&lt;br /&gt;Thanks.&lt;br&gt;&lt;br&gt;Posted to: Error: 'ParentID' appears twice</description>
			<pubDate>Fri, 16 May 2008 11:31:57 +1200</pubDate>
			<author>Shane Garelja</author>
			<guid>http://www.silverstripe.com/site-builders-forum/show/73956</guid>
		</item>
		

	</channel>
</rss>
