To reproduce:

  • Install D7 + backbone + backbone_example
  • Create an article with published, promoted, and sticky unchecked
  • Open browser's JS console and execute following:
    var m = new Drupal.Backbone.Models.Node;
    m.set({nid: 1});
    m.fetch();
    m.save({title: 'new title'});
  • Surf to /node/1/edit to confirm that all three boolean fields (published, promoted, sticky are now checked)

Examining the PUT request, the sent values are correct, so it appears to be something on the Drupal/PHP side. Bellow is the JSON sent in the request

  • {
       "node":{
          "nid":"1",
          "vid":"1",
          "uid":"1",
          "title":"new title",
          "log":"",
          "status":"0",
          "comment":"1",
          "promote":"0",
          "sticky":"0",
          "type":"article",
          "language":"und",
          "created":"1336140139",
          "changed":"1336141992",
          "tnid":"0",
          "translate":"0",
          "revision_timestamp":"1336141992",
          "revision_uid":"1",
          "body":{
             "und":[
                {
                   "value":"Super duper!!!",
                   "summary":"",
                   "format":"filtered_html",
                   "safe_value":"<p>Super duper!!!</p>\n",
                   "safe_summary":""
                }
             ]
          },
          "field_tags":[
    
          ],
          "field_image":[
    
          ],
          "rdf_mapping":{
             "field_image":{
                "predicates":[
                   "og:image",
                   "rdfs:seeAlso"
                ],
                "type":"rel"
             },
             "field_tags":{
                "predicates":[
                   "dc:subject"
                ],
                "type":"rel"
             },
             "rdftype":[
                "sioc:Item",
                "foaf:Document"
             ],
             "title":{
                "predicates":[
                   "dc:title"
                ]
             },
             "created":{
                "predicates":[
                   "dc:date",
                   "dc:created"
                ],
                "datatype":"xsd:dateTime",
                "callback":"date_iso8601"
             },
             "changed":{
                "predicates":[
                   "dc:modified"
                ],
                "datatype":"xsd:dateTime",
                "callback":"date_iso8601"
             },
             "body":{
                "predicates":[
                   "content:encoded"
                ]
             },
             "uid":{
                "predicates":[
                   "sioc:has_creator"
                ],
                "type":"rel"
             },
             "name":{
                "predicates":[
                   "foaf:name"
                ]
             },
             "comment_count":{
                "predicates":[
                   "sioc:num_replies"
                ],
                "datatype":"xsd:integer"
             },
             "last_activity":{
                "predicates":[
                   "sioc:last_activity_date"
                ],
                "datatype":"xsd:dateTime",
                "callback":"date_iso8601"
             }
          },
          "cid":"0",
          "last_comment_timestamp":"1336140139",
          "last_comment_name":null,
          "last_comment_uid":"1",
          "comment_count":"0",
          "name":"root",
          "picture":"0",
          "data":"b:0;",
          "path":"http://t.dev/node/1"
       }
    }

Comments

setvik’s picture

Looks like this is a Services issue:

http://drupal.org/node/1511662

ethanw’s picture

Status: Active » Fixed

This should now be resolved, as of http://drupalcode.org/project/backbone.git/commit/8ad2b92.

Addressed by adding a flexible JSON processor system that lets individual fields have custom processors assigned to them and run when converting to the pre-JSON object format.

Currently the drupalbackbone-services.js module only has one, for booleans, but others are possible and probably likely.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.