jbeuckm / drupal-client

Javascript client for Drupal Services
32 stars 10 forks source link

Checkbox fields are not updating #10

Open max1020 opened 10 years ago

max1020 commented 10 years ago

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,

jbeuckm commented 10 years ago

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?

medrockstar commented 10 years ago

any solution ?

jbeuckm commented 10 years ago

Not yet - I'm just using integers.

max1020 commented 10 years ago

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,

medrockstar commented 10 years ago

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:'test@example.com', field_boolean : checkBoxField("non") };

max1020 commented 10 years ago

hey!

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

jbeuckm commented 10 years ago

As always, pull requests appreciated.

max1020 commented 10 years ago

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 commented 10 years ago

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.