【问题标题】:SilverStripe return URLSegment from SiteTree relationSilverStripe 从 SiteTree 关系返回 URLSegment
【发布时间】:2016-10-17 10:02:15
【问题描述】:

所以我有这个:

private static $has_one = array(
    'ButtonLink' => 'SiteTree'
);

还有这个字段

$fields->addFieldToTab('Root.Main', TreeDropdownField::create("ButtonLink", "Page link", "SiteTree"));

以便用户可以将此 DataObject 链接到 SiteTree 中的页面。在前端,我试图将URLSegment 返回为:

$ButtonLink.Link

但它不返回任何东西。

【问题讨论】:

    标签: php silverstripe


    【解决方案1】:

    找到了。您需要将 ID 附加到字段标识符,因为这是保存外部记录引用键的 db 列名称(SiteTree)。

    $fields->addFieldToTab('Root.Main', TreeDropdownField::create("ButtonLinkID", "Page link", "SiteTree"));
    

    【讨论】:

      猜你喜欢
      • 2014-10-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-09-23
      • 2012-11-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多