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.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Silverstripe 2.47 development problems


Go to End


3 Posts   1535 Views

Avatar
slavelabourer

Community Member, 26 Posts

1 November 2012 at 4:36pm

Hi guys,

I'm trying to pick this up again after a long time away. I've got some pretty confusing problems to get started.


static $db = array (
   'Venue' => 'text'
)

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

function getCMSFields() {
   		$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Content.Main', new DropdownField(
   		    'Venue',
   		    'Choose a Venue',
   			Dataobject::get("VenuePage")->map("ID", "Title", "Please Select", "", $this)), 
   		'Content');
   		
		/* get venuepage */
   		$fields->addFieldToTab('Root.Content.Main', new DropdownField(
   		    'TheVenue',
   		    'Choose a Venue',
   			Dataobject::get("VenuePage")->map("ID", "Title", "Please Select", "", $this)), 
   		'Content');

Venue works
TheVenue seems to break the parent page VenueHolder and I can no longer save any pages in the cms even after removing the changes in the code.

I want to add a has_one relationship of an Event page to a venue page, however doing this breaks the cms and I can no longer publish any of the pages even after I remove the change and ?flush=all

Secondly I want to display the data of the selected Venue but $Venue only displays the table ID how can I get all the data in the row using DataObject get?

These are likely easy fixes but with not alot of experience, documentation and no error output I'm at a complete loss as to how I should start troubleshooting?

any advice is apperciated,
cheers,
dan.

Avatar
Carbon Crayon

Community Member, 598 Posts

1 November 2012 at 9:16pm

Hi slavelabourer,

Not sure if this is your problem, but your ->map() definition is slightly wrong, you only need to pass it 3 arguments and I normally wrap the whole field definition in a confitional to ensure you don't get any errors if you dont have any VenuPages. You also need to add 'ID' to the end of the fieldname for it to save correclty when using a Dropdown for a has_one:


if($options = DataObject::get('VenuePage'))
{
	$fields->addFieldToTab('Root.Content.Main', new DropdownField('TheVenueID', 'Choose a Venue', $options->map('ID', 'Titlte', 'Please Select'),"Content");
}

Aram

www.SSBits.com - SilverStripe Tutorials, tips and other bits.

Avatar
slavelabourer

Community Member, 26 Posts

1 November 2012 at 9:46pm

Perfect answer thanks so much!

Frustrating being so close. and I figured out the not being able to save anything was because ss couldn't find editor.css as I had set the default theme to one that no longer exists.

thanks Aram,
and thanks for ss bits it's an invaluable resource!

peace :)
dan.