【问题标题】:Silverstripe: I can't handle sub-URLs of a Form object. Subsites moduleSilverstripe:我无法处理 Form 对象的子 URL。子网站模块
【发布时间】:2012-07-10 04:10:59
【问题描述】:

有点长镜头,但任何人都可以对此有所了解吗?

我最近安装了 subsites 模块,以便通过一次安装运行多个站点,现在收到错误消息:“我无法处理 Form 对象的子 URL。”当我尝试向图片库对象添加描述/标题时。我已删除子站点以验证是否是导致问题的原因。我正在使用 2.4

我可以很好地上传图片,但是在尝试从弹出窗口中保存描述时出现问题。

我也尝试过使用默认字段,但仍然出现同样的错误。

我的代码:

<?php

class Gallery extends Page {

   public static $db = array( 
      'SummaryText'=>'Text', 
      'GalleryText'=>'Text' 
   ); 

   static $has_many = array( 
      'Photos' => 'GalleryPhoto' 
   ); 

   function getCMSFields() { 
      $fields = parent::getCMSFields(); 


      $manager = new ImageDataObjectManager( 
         $this, // Controller 
         'Photos', // Source name 
         'GalleryPhoto', // Source class 
         'Image' // File name on DataObject 
      ); 
      $manager->uploadFolder = $this->URLSegment; 


      $fields->addFieldToTab('Root.Content.Main', new TextField('SummaryText', 'Summary Text (Appears in the section preview)'), 'Content'); 
      $fields->addFieldToTab('Root.Content.Main', new TextField('GalleryText', 'Gallery Text (entering anything in here will overwrite any image Titles and Descriptions)'), 'Content'); 
      $fields->addFieldsToTab("Root.Content.Gallery", array($manager));             
      $fields->removeFieldFromTab('Root.Content', 'StyledText'); 
      $fields->removeFieldFromTab('Root.Content', 'Column2'); 
      $fields->removeFieldFromTab('Root.Content', 'Content'); 


      return $fields; 

   } 


}

..

<?php

class GalleryPhoto extends Photo {

   public static $db = array( 
      'HTMLDescription'=>'HTMLText' 
   ); 

   static $has_one = array( 
      'Gallery' => 'Gallery' 
   ); 

   public function getCMSFields(){ 
      $fields = parent::getCMSFields(); 
      $fields->removebyname('Description'); 
      $fields->removebyname('Title'); 
      $fields->replaceField('HTMLDescription', new SimpleTinyMCEField('HTMLDescription')); 
      return $fields; 
   } 
}

【问题讨论】:

    标签: php silverstripe


    【解决方案1】:

    很遗憾,“我无法处理 Form 对象的子 URL。”是一个非常通用的错误消息,根据我的经验,调试起来相当棘手。

    老实说,我认为 Subsites 模块并不是那么好,它可以工作,但它不是很好,而且我猜它与其他模块不兼容。

    我可以想象您出错的原因是因为 silverstripe 忘记了弹出窗口中的 SubsiteID,因此 SilverStripe 无法再找到您正在编辑的当前页面(因为它在每个查询中添加了一个过滤器 WHERE SubsiteID = x您制作的页面)

    开始调试的一个地方是连接到 Subsite::currentSubsiteID() 并查看当您在弹出窗口中时它是否记得 SubsiteID

    另外,当您收到错误消息时,调用的确切 url 是什么?

    【讨论】:

      【解决方案2】:

      我刚刚遇到同样的错误,搜索了几个小时。这是 /framework/control/Session.php 的问题

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2018-03-23
        • 1970-01-01
        • 1970-01-01
        • 2022-10-19
        • 2016-04-25
        • 1970-01-01
        • 2010-09-11
        相关资源
        最近更新 更多