【发布时间】:2013-05-03 07:44:43
【问题描述】:
我添加的一些选项卡字段存在一些问题,它们没有保存放置在其中的数据。我知道它与 $db 数组有关,但是当我尝试 /dev/build 时,我无法让它正常工作。
这是我的代码 sn-p。我正在尝试添加 5 个 HTMLEditorFields,如下所示。我对此很陌生,但我遇到的所有帖子都表明我做对了?
http://www.silverstripe.org/customising-the-cms/show/4496
http://www.silverstripe.org/customising-the-cms/show/9391
http://www.silverstripe.org/general-questions/show/9001
我想知道是否有人可以指出我的问题可能是什么?
<?php
class HomePage extends Page {
static $db = array(
'contentBottom' => 'HTMLText',
'centerTop' => 'HTMLText',
'centerBottom' => 'HTMLText',
'rightTop' => 'HTMLText',
'rightBottom' => 'HTMLText'
);
function getCMSFields() {
$fields = parent::getCMSFields();
// Content
$fields->addFieldToTab('Root.Content.Main', new HtmlEditorField('contentBottom'));
$fields->addFieldToTab('Root.Content.Main', new HtmlEditorField('centerTop'));
$fields->addFieldToTab('Root.Content.Main', new HtmlEditorField('centerBottom'));
$fields->addFieldToTab('Root.Content.Main', new HtmlEditorField('rightTop'));
$fields->addFieldToTab('Root.Content.Main', new HtmlEditorField('rightBottom'));
return $fields;
}
}
class HomePage_Controller extends Page_Controller {
public function init() {
parent::init();
}
}
错误:
[Notice] Array to string conversion
GET /<site_name>/dev/build
Line 396 in F:\Programs\XAMPP\htdocs\<site_Name>\sapphire\core\model\Database.php
Source
387 $array_spec = $this->indexList[$table][$index_alt]['spec'];
388 } else {
389 $array_spec = $this->indexList[$table][$index_alt];
390 }
391 }
392 }
393
394 if($newTable || !isset($this->indexList[$table][$index_alt])) {
395 $this->transCreateIndex($table, $index, $spec);
396 $this->alterationMessage("Index $table.$index: created as $spec","created");
397 } else if($array_spec != DB::getConn()->convertIndexSpec($spec)) {
398 $this->transAlterIndex($table, $index, $spec);
399 $spec_msg=DB::getConn()->convertIndexSpec($spec);
400 $this->alterationMessage("Index $table.$index: changed to $spec_msg <i style=\"color: #AAA\">(from {$array_spec})</i>","changed");
401 }
402 }
【问题讨论】:
-
开发/构建的错误是什么?
-
@schellmax 我已将其添加到说明中 :)
-
猜你在 php 5.4 上?你可以尝试降级到 php 5.3,将 silverstripe 升级到 3.0,或者禁用 php 警告
-
@schellmax 这真的有必要吗? Doco 的东西似乎说 >=5.2 例如在这里:versioneye.com/package/php--silverstripe--cms/version/2~4~9
-
2.4 版似乎与 5.4 不兼容,请参见例如silverstripe.org/installing-silverstripe/show/19456
标签: php mysql content-management-system silverstripe