Hello.
After some time I've downloaded the latest dev versions of the updated sdk and of the drupal module of drupalgap too. My website provides i18 support.
In my website I can see the list of different nodes with their own language (eng or it)

When I try to edit the body of a node (with some other fields too, like addressfield etc) in the webapp, I get an empty field in the body.
In the console I get:

drupalgap_field_info_instances_add_to_form - TypeError: entity[name][language] is undefined

in drupalgap.js

In the sdk I've configured the use of locale by setting a default language (it) and enabled some of the json translations from the "locale" folder

Probably the issue has something to do with other similar, but I'm not able to fix it. I've red some other posts about similar errors but I don't know where to put the hands...

Comments

tyler.frankenstein’s picture

Status: Active » Postponed (maintainer needs more info)

Will you please share the links to the other issues/mentions of this issue?

If I recall correctly (again I'm not a multi lingual Drupal master, I've really only ever used 'und' out of the box Drupal, and have minimal experience with multi lingual sites), I think the problem is let's say for example we had this node:

{
  title: 'Hello world',
  type: 'article',
  language: 'it',
  body: {
    und: [ { value: 'Goodbye world' } ]
  }
}

As we can see the language code is it, but I think Drupal returns und for each field language code. Will you please confirm or deny this with a few sample nodes on your site?

Either way, I think I programmed the SDK to always fallback to und on fields, if there is no matching language code. But after further review, I don't think I did implement that fallback, so it is probably trying to access a language code on a field, and that doesn't exist. The problem is probably very close to here:

https://github.com/signalpoint/DrupalGap/blob/7.x-1.x/src/modules/field/...

kinmen’s picture

Thank you for the answer.

I've thought it could be something similar to:
https://www.drupal.org/node/2441981 or
https://www.drupal.org/node/2470475

I didn't mention it before, but the localization of the webapp isn't working either, but I don't know if it has something to to with the issue above...

btw, the json of a test node shows und for field body, as well as for the other fields in the sam node:

{
    "vid":"58",
    "uid":"1",
    "title":"test multilingua",
    "log":"",
    "status":"1",
    "comment":"2",
    "promote":"1",
    "sticky":"0",
    "nid":"58",
    "type":"article",
    "language":"it",
    "created":"1435580442",
    "changed":"1435580442",
    "tnid":"0",
    "translate":"0",
    "revision_timestamp":"1435580442",
    "revision_uid":"1",
    "body":
        {"und":[
            {"value":"trallallero",
            "summary":"",
            "format":"filtered_html",
            "safe_value":"<p>trallallero</p>\n",
            "safe_summary":""}]
        },
    "field_tags":
        {"und":[
            {"tid":"20","name":"other"}]},
    "field_image":[],
    "field_venue_address":[],
    "field_venue_location":[],
    "field_map":[],
    "field_find_location":
        {"und":[{"geom":"POINT (11.6033512 48.1381386)",
                "geo_type":"point",
                "lat":"48.138138600000",
                "lon":"11.603351200000", 

...

I've omitted the last rows cause are just data. I Hope now it's readable
tnx again

tyler.frankenstein’s picture

Please edit your comment to wrap the JSON in code brackets, or else it is un-readable.

Next, do a console.log(name); during the loop linked in the source code above. What field(s) are crashing out?

kinmen’s picture

In field.js? Which row exactly? Sorry but I'm not able to program neither js nor other languages... :-/

tyler.frankenstein’s picture

Download the latest bin/drupalgap.js file, I just added an extra null checker that should fix your problem.

kinmen’s picture

I've downloaded it, cleared browser's cache, and now the console of FF shows:

GET http://mywebsite/drupal/?q=drupalgap/node/41.json 200 OK 1,07s jdrupal....min.js (riga 35)
200 - OK jdrupal....min.js (riga 32)
WARNING: _drupalgap_form_render_element() - geocoder_field_widget_form() does not exist for the "geofield" form element!    drupalgap.js (riga 2919)
WARNING: _drupalgap_form_render_element_item() - Field undefined not supported.     drupalgap.js (riga 3195)
{"id":"edit-node-edit-field-venue-location-it-0-value","options":{"attributes":{"id":"edit-node-edit-field-venue-location-it-0-value"}},"required":0,"children":[],"title":"Location","default_value":""}   jdrupal....min.js (riga 7)
WARNING: _drupalgap_form_render_element() - geocoder_field_widget_form() does not exist for the "geofield" form element!    drupalgap.js (riga 2919)
WARNING: _drupalgap_form_render_element_item() - Field undefined not supported.     drupalgap.js (riga 3195)
{"id":"edit-node-edit-field-map-it-0-value","options":{"attributes":{"id":"edit-node-edit-field-map-it-0-value"}},"required":0,"children":[],"title":"Map","default_value":""}      jdrupal....min.js (riga 7)
GET: http://mywebsite/drupal/?q=drupalgap/taxonomy_term.json&parameters[vid]=1   jdrupal....min.js (riga 31)
GET http://mywebsite/drupal/?q=drupalgap/taxonomy_term.json&parameters[vid]=1 200 OK 630ms jdrupal....min.js (riga 35)
POST: http://mywebsite/drupal/?q=drupalgap/services_addressfield/country_get_list.json   jdrupal....min.js (riga 31)
POST http://mywebsite/drupal/?q=drupalgap/services_addressfield/country_get_list.json 200 OK 797ms jdrupal....min.js (riga 35)
2
200 - OK

I've just noted that not just the body field is empty in the Edit window, but also the other fields, excluded the title are empty: taxonomy term, lat/long...

Thank you for the help

kinmen’s picture

Yesterday I've updated the SDK, and now I'm getting something more:

GET: http://mywebsite/drupal/?q=drupalgap/node/47.json
jdrupal....min.js (riga 30)
GET http://mywebsite/drupal/?q=drupalgap/node/47.json
	
200 OK
		769ms	
jdrupal....min.js (riga 34)
200 - OK
jdrupal....min.js (riga 31)
geofield_field_formatter_view - TypeError: entity[field.field_name][langcode] is undefined
jquery-... > eval (riga 24)
WARNING: _drupalgap_form_render_element() - geocoder_field_widget_form() does not exist for the "geofield" form element!
drupalg....min.js (riga 86)
WARNING: _drupalgap_form_render_element_item() - Field undefined not supported.
drupalg....min.js (riga 91)
{"id":"edit-node-edit-field-venue-location-und-0-value","options":{"attributes":{"id":"edit-node-edit-field-venue-location-und-0-value"}},"required":0,"children":[],"title":"Location","default_value":""}
jdrupal....min.js (riga 7)
Object { id="edit-node-edit-field-venue-location-und-0-value",  options={...},  required=0,  altri elementi...}
jdrupal....min.js (riga 7)
WARNING: _drupalgap_form_render_element() - geocoder_field_widget_form() does not exist for the "geofield" form element!
drupalg....min.js (riga 86)
WARNING: _drupalgap_form_render_element_item() - Field undefined not supported.
drupalg....min.js (riga 91)
{"id":"edit-node-edit-field-map-und-0-value","options":{"attributes":{"id":"edit-node-edit-field-map-und-0-value"}},"required":0,"children":[],"title":"Map","default_value":""}
jdrupal....min.js (riga 7)
Object { id="edit-node-edit-field-map-und-0-value",  options={...},  required=0,  altri elementi...}
jdrupal....min.js (riga 7)
GET: http://mywebsite/drupal/?q=drupalgap/taxonomy_term.json&parameters[vid]=1
jdrupal....min.js (riga 30)

drupalgap 7.x-1.13+ sdk 7.x-1.x, also entity reference module for both...

At the moment I can't either save a new article, I'm getting the following error when I click on SAVE:

drupalgap_entity_build_from_form_state - TypeError: c[e] is undefined
drupalg....min.js (riga 224)
drupalgap_entity_form_submit - TypeError: c is undefined
tyler.frankenstein’s picture

geofield_field_formatter_view - TypeError: entity[field.field_name][langcode] is undefined

I've noticed on multilingual sites that an entity will have a certain language code, but then that language code doesn't exist on the entity's fields from time to time. I thought we programmed a handler to catch that and fall back to 'und'.

WARNING: _drupalgap_form_render_element() - geocoder_field_widget_form() does not exist for the "geofield" form element!

There is no support (AFAIK) yet for geocoder in DrupalGap. Any geocoder events server side should be fine though. Adding support for geocoder in DG shouldn't be too bad, hook_field_formatter_view() and hook_field_widget_form() in an app/modules/geocoder/geocoder.js file would get started.

drupalgap_entity_form_submit - TypeError: c is undefined

Have you tried the non minified drupalgap.js file? Also try the non minified jdrupal.js file.

kinmen’s picture

Thank you for the answer.
Switched to drupalgap.js + jdrupal.js, and now when I click on SAVE I get:

drupalgap_entity_build_from_form_state - TypeError: entity[name] is undefined
drupalgap.js (riga 7945)
drupalgap_entity_form_submit - TypeError: entity is undefined
tyler.frankenstein’s picture

drupalgap_entity_form_submit - TypeError: entity is undefined

I'd recommend walking through the drupalgap_entity_build_from_form_state() function, and doing dpm/console prints to see what is going on.

https://github.com/signalpoint/DrupalGap/blob/7.x-1.x/src/modules/entity...

jomarocas’s picture

you solution this, because im getting same errors, i cannot edit nodes correctly and edit user

jomarocas’s picture

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

When i put the language in "und", i create a node and i can see the node with the content, but when i go to edit content, i cannot see the fields with the content that i make, but when i push other language in "und" i create node, and only see the title, but i dont see the content, and i cannot see the fields that i write in edit content, this is the same when i edit user i cannot see nothing field that i use when register. thanks

logs
when i create content

[phonegap] [console.log] POST: ?q=drupalgap/node.json
[phonegap] [console.log] {"nid":"","title":"Testing","type":"notas","language":"und","body":{"und":[{"value":"Ahhhfj"}]},"field_descripcion_larga":{"und":[{"value":"Jfjjjkfllf"}]}}
[phonegap] [console.log] 200 - OK
[phonegap] 200 /__api__/autoreload
[phonegap] [console.log] WARNING: drupalgap_remove_page_from_dom() - not removing the current page (node_add_notas) from the DOM!
[phonegap] [console.log] GET: ?q=drupalgap/node/85.json
[phonegap] [console.log] 200 - OK
[phonegap] [console.log] WARNING: theme_undefined() does not exist. Called by: drupalgap_render_page().
[phonegap] [console.warn] No Content-Security-Policy meta tag found. Please add one when using the cordova-plugin-whitelist plugin.

when i edit content

[phonegap] [console.warn] No Content-Security-Policy meta tag found. Please add one when using the cordova-plugin-whitelist plugin.
[phonegap] [console.log] GET: /?q=drupalgap/node/83.json
[phonegap] 200 /__api__/autoreload
[phonegap] [console.log] 200 - OK
[phonegap] [console.log] WARNING: theme_undefined() does not exist. Called by: drupalgap_render_page().
[phonegap] [console.log] GET: /?q=drupalgap/node/83.json

when i get the value in poster all is right, have the values, but dont show


{"vid":"85","uid":"110","title":"Testing","log":"","status":"1","comment":"1","promote":"0","sticky":"0","vuuid":"db04d08e-1ea0-46c7-9abc-a7d1b3575ab0","nid":"85","type":"notas","language":"es","created":"1461625364","changed":"1461625364","tnid":"0","translate":"0","uuid":"54ec3ef9-feba-401a-9dbe-51a6e7994a28","revision_timestamp":"1461625364","revision_uid":"110","body":{"und":[{"value":"Ahhhfj","summary":"","format":null,"safe_value":"Ahhhfj","safe_summary":""}]},"field_descripcion_larga":{"und":[{"value":"Jfjjjkfllf","summary":"","format":null,"safe_value":"Jfjjjkfllf","safe_summary":""}]},"path":"/content/testing","cid":"0","last_comment_timestamp":"1461625364","last_comment_name":null,"last_comment_uid":"110","comment_count":"0","name":"Gnf","picture":"0","data":"a:1:{s:34:\"user_relationships_ui_auto_approve\";a:0:{}}","user_relationship_node_access":false}

i want help to make something to correct this, but i dont know where to start or how as do to correct these in my language

jomarocas’s picture

Status: Needs review » Active