我添加的某些选项卡字段存在一些问题,没有保存放置在其中的数据。我知道它与$ 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     }

最佳答案

正如Schellmax建议的那样,这里的问题是,我已经用php 5.3安装了XAMPP的早期版本,并且现在应该可以正常工作了……

关于php - Silverstripe页面模板保存到数据库问题,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/16353935/

10-11 05:15
查看更多