drupal-client icon indicating copy to clipboard operation
drupal-client copied to clipboard

Checkbox fields are not updating

Open max1020 opened this issue 11 years ago • 9 comments
trafficstars

Hello Joe,

Great to see that you continue to work on this project. ive picked up working on the documentation and the app again so i thought id report this issue here. im using services 3.7 but this shouldnt have an impact on the checkboxes, no?

its primarily about checkboxes (on user profile) that are not being updated (or set to "0" in the example). the decimal and text fields are correctly updated when passing the object to the drupal.putResource function.

var object = {
    field_smilies: drupal.field.structureField("666"), // --> DECIMAL FIELD WORKS
    field_city: drupal.field.structureField("test666"), // --> TEXT FIELD WORKS
    //CHECKBOXES --> CANT GET THEM TO WORK      
    field_serious: drupal.field.structureField(0), // DOESNT SET field_serious (machine name) TO false or 0 on profile, but "user has been updated."shows up in console
    field_serious1: drupal.field.structureField(0),
};

Ive attached a screenshot as well showing details about this (taxonomy terms are not mentioned in the README file, so i guess you are aware of that). ive tried all widgets for taxonomy terms (also autocomplete doesnt work, this works with an organic group reference field though).

profile update

cheerios,

max1020 avatar Aug 31 '14 09:08 max1020

I agree - checkboxes are not working. I had to use an integer for one project, but I hope there will be a way to make legitimate checkbox boolean fields work. Have you had any luck with this?

jbeuckm avatar Sep 17 '14 14:09 jbeuckm

any solution ?

medrockstar avatar Sep 17 '14 14:09 medrockstar

Not yet - I'm just using integers.

jbeuckm avatar Sep 17 '14 14:09 jbeuckm

hello Joe,

nope, i had no success with the checkboxes and taxonomy terms unfortunately.

but its a good suggestion with the integer. many thanks!

ill use the integer fields in the drupal backend instead of checkboxes and add a comment in the readme file. i spent quite a bit of time on this.

cheerios,

max1020 avatar Sep 18 '14 07:09 max1020

Hi all,

I found ths solution for checkBox and SelectField hhh :

function selectListField(value){ var selectList = { "und": [value] }; return selectList; }

function checkBoxField(value){ var checkBox = { "und": value }; return checkBox; }

Example :

var a = "a"; var user = {name:a, current_pass:a, mail:'[email protected]', field_boolean : checkBoxField("non") };

medrockstar avatar Sep 23 '14 10:09 medrockstar

hey!

would be great if that did the trick - im gonna try this later this week and provide feedback. thanks in any case.

max1020 avatar Sep 23 '14 10:09 max1020

As always, pull requests appreciated.

jbeuckm avatar Sep 23 '14 17:09 jbeuckm

hello medrockstar,

did you manage to get the checkbox function to work? i didnt - see the attached screenshot. the json structure is different when using the checkbox function.

checkbox field

also, drupal services seems to return only "1" and "0" (regardless of what is entered as "on" and "off" value in the drupal boolean field).

max1020 avatar Sep 28 '14 08:09 max1020

here is part of the object what works for me (text fields instead of boolean). titanium returns switch values of "true"and "false" (whereas drupal works with "0" and "1" so i used a text field)

field_serious_ch: drupal.field.structureField("" + $.serious.value + ""),
field_fun_ch: drupal.field.structureField("" + $.fun.value + ""),
field_politics_ch: drupal.field.structureField("" + $.politics.value + ""),

i have 3 switches called serious, fun and politics.

max1020 avatar Sep 28 '14 09:09 max1020