Jump to:

5450 Posts in 1672 Topics by 1197 members

Customising the CMS

SilverStripe Forums » Customising the CMS » Can't save a link from the CMS to the database

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

Page: 1
Go to End
Author Topic: 905 Views
  • evjan
    Avatar
    Community Member
    7 Posts

    Can't save a link from the CMS to the database Link to this post

    Hi,

    I'm trying do modify the template for a page so that the admin can select where a certain element on the page redirects. I'm trying to use something like the following:

    static $has_one= array(
    "InternalLink" => "SiteTree"
    );

    The field shows up in the CMS and I can edit the link. But when I save it it doesn't seem to be persisted into the database, and the link when viewing the page just points to $siteroot//

    I've built the site and a field called examplenameID does show up in the database. But it never changes from 0.

    What am I doing wrong?

    Kind regards
    Peter (a silverstripe newbie)

  • Willr
    Avatar
    Forum Moderator
    5464 Posts

    Re: Can't save a link from the CMS to the database Link to this post

    Are you using a TreeDropdown field for selecting the site tree or a dropdown field?.

    With these you will need to make sure that the field name includes the id - RelationshipNameID rather then just RelationshipName

    new TreeDropdownField('InternalLinkID', 'Link'...

  • evjan
    Avatar
    Community Member
    7 Posts

    Re: Can't save a link from the CMS to the database Link to this post

    That was the key, I changed the parameter and everything started working.

    Thanks!

    905 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.