If I add taxonomy term to user profile on drupal and If I try to update user profile from drupalgap, I get following error:

PS: I don't update taxonomy terms, I just update another field in user profile with following code:

		if (Drupal.user.uid > 0) {
			user_load(Drupal.user.uid, {
				success:function(account) {
					account['field_user_alarm_yeni']['und'][0]['value'] = user_alarm_yeni;
					account['field_user_alarm_konum']['und'][0]['value'] = user_alarm_konum;
					user_update(account, {
						success: function(result) {
						},
						error:function(xhr, status, message){
							alert('fail: '+message);
						}
					});	
				}
			});
		}

I get these error messages from drupalgap application. If I remove these taxonomy terms from user profile, update will be successful.

{"form_errors":{"field_user_kategori][und":"An illegal choice has been detected. Please contact the site administrator.","field_user_firma][und":"An illegal choice has been detected. Please contact the site administrator.","field_user_sektor][und":"An illegal choice has been detected. Please contact the site administrator."}}

Comments

coolman7’s picture

Title: taxonomy » taxonomy term problem on user profile
tyler.frankenstein’s picture

Category: Bug report » Support request
Status: Active » Postponed (maintainer needs more info)

It depends on what widget you are using for that field on your user profiles, and that determines what shape you must send your object/array. But it'll probably be something like this:

http://drupal.stackexchange.com/a/106395/10645

field_foo['und']=bar

From my understanding, I thought DrupalGap core already supported taxonomy term reference fields and should be able to handle them on User Profiles.

coolman7’s picture

I'm using "Select list" widget. I tested with other two widgets (checkbox and autocomplete) widgets.
Checkbox widget gave same result with select list widget.
autocomplete widget gave different result. It saves the user data, but at the same time it losts taxonomy data.

From the error message I get: {"form_errors":{"field_user_kategori][und"
[ character is missing at the beginning and ] character is missing at the end. Is it possible this cause the problem?

There might be some problems with custom taxonomy fields at user profile content type. At profile page, taxonomy terms are displayed as term id instead of term name. But they are shown correctly at nodes.

tyler.frankenstein’s picture

To get the term names (instead of term ids) to show up on user profiles, take a look at this function here:

http://cgit.drupalcode.org/drupalgap/tree/drupalgap.module#n200

A case needs to be added for User entities, and that should grab the term names for display within the app.

The actual widget for a taxonomy term reference needs improvement as well, the select/radio/checkboxes all behave like a select list at this point, so that needs to be expanded: https://github.com/signalpoint/DrupalGap/blob/7.x-1.x/src/modules/taxono... -

This issue is also related: https://github.com/signalpoint/DrupalGap/issues/245

gisle’s picture

Status: Postponed (maintainer needs more info) » Needs review

The suggestion in #4 should be reviewed.