21491 Posts in 5783 Topics by 2622 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 151 Views |
-
Silverstripe 2.47 development problems

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. -
Re: Silverstripe 2.47 development problems

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.
-
Re: Silverstripe 2.47 development problems

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.
| 151 Views | ||
|
Page:
1
|
Go to Top |


