I'm using updateSingleValue like this:
$updated = $this->app['storage']->updateSingleValue('suggestions', $id, 'votes', $value);
The $id
and $value
are set correctly (even if I set them to correct integers manually), and there definitely exists a suggestions
contenttype with votes
field. Yet, this function returns false
, suggesting that !$this->isValidColumn($field, $contenttype)
fails.
A suggestion
in json format looks like this:
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"
},
The suggestion contenttype looks like this:
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
What can I be doing wrong here?
Found the problem here the contenttype passed into updateSingleValue needs to be the entire contenttype not just the slug 'suggestions'. You can fetch it via the storage class method:
$app['storage']->getContentType('suggestions')
then pass in the result of that to the updateSingleValue method.