Jump to:

22997 Posts in 11620 Topics by 2827 members

General Questions

SilverStripe Forums » General Questions » Silverstripe 2.47 development problems

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

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

Page: 1
Go to End
Author Topic: 254 Views
  • slavelabourer
    Avatar
    Community Member
    25 Posts

    Silverstripe 2.47 development problems Link to this post

    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.

  • Aram
    Avatar
    Community Member
    598 Posts

    Re: Silverstripe 2.47 development problems Link to this post

    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.

  • slavelabourer
    Avatar
    Community Member
    25 Posts

    Re: Silverstripe 2.47 development problems Link to this post

    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.

    254 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.