updateSingleValue()返回false,但输入正确

时间:2015-01-03 16:00:34

标签: bolt-cms

我正在使用updateSingleValue:

$updated = $this->app['storage']->updateSingleValue('suggestions', $id, 'votes', $value);

$id$value设置正确(即使我将它们设置为手动校正整数),并且肯定存在suggestions内容类型votes字段。然而,此函数返回false,表明!$this->isValidColumn($field, $contenttype)失败。

json格式的suggestion如下所示:

suggestion": {
"id": "25",
"values": {
    "datechanged": "2015-01-03 13:25:02",
    "id": "25",
    "slug": "slug-o2sbdb",
    "datecreated": "2015-01-03 13:25:02",
    "datepublish": "2015-01-03 13:25:02",
    "datedepublish": "1900-01-01 00:00:00",
    "ownerid": "1",
    "status": "published",
    "title": "test title",
    "description": "test description",
    "votes": "0"
},

建议contenttype如下所示:

suggestions:
    name: Suggestions
    slug: suggestions
    singular_name: Suggestion
    singular_slug: suggestion
    default_status: publish
    fields:
        title:
            label: Title
            type: text
            class: large
            required: true
            pattern: ".{2,255}" # see: http://html5pattern.com/
            error: "The Title field is required, and must contain at least 2 characters"
        description:
            label: Description
            type: textarea
        votes:
            label: Votes
            type: integer

我在这里做错了什么?

1 个答案:

答案 0 :(得分:0)

在这里发现问题,传递给updateSingleValue的contenttype需要是整个内容类型,而不仅仅是slug'admintions'。您可以通过存储类方法获取它:

$app['storage']->getContentType('suggestions')

然后将结果传递给updateSingleValue方法。