我添加的一些选项卡字段存在一些问题,没有保存放置在其中的数据。我知道它与 $db 数组有关,但是当我尝试 /dev/build 时,我无法让它正常工作。
这是我的代码片段。我正在尝试添加 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 }