银条:我可以';t处理Form对象的子URL.子站点模块


Silverstripe: I can't handle sub-URLs of a Form object. Subsites module

这是一个很长的机会,但有人能阐明这一点吗?

我最近安装了子网站模块,以便在一次安装中运行多个网站,当我尝试向图像库对象添加描述/标题时,现在收到错误:"我无法处理表单对象的子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; 
   } 
}

不幸的是,"我无法处理Form对象的子URL。"是一个非常常见的错误消息,根据我的经验,调试起来相当棘手。

老实说,在我看来,Subsites模块并不是很好,它可以工作,但它并不是那么好,我想它与其他模块也不兼容。

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

一个开始调试的地方是挂入Subsite::currentSubsiteID(),看看当你在弹出的中时它是否记得SubsiteID

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

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

的问题