I use Drupal 7, Drupalgap1.8, cordova4.0.0.
All other functions works nice. Tile and body field in node edit form disappeared when i visit node edit page.

Comments

tyler.frankenstein’s picture

Status: Active » Postponed (maintainer needs more info)

Are you using a multi lingual site or any language codes?

What is your Ripple URL to test?

g089h515r806’s picture

The Ripple URL is, http://localhost/zhangzhongbao/dg.

For field, the languange code is "und".

In node edit form, only save,delete button display.
In term edit form, term name, description,save, delete button display, custom field which added to this term is disappeared.

login form is correct.

g089h515r806’s picture

At last I find the reason.
The weight of the field is < 0.
Index of js array could not < 0.

one solution is:
rearange the field order at manage field page, make sure that all fields's weight is not <0.

Another solution is change the code of _drupalgap_form_render_elements, to make sure that the weight is > 0.

here is my code:

function _drupalgap_form_render_elements(form) {
  try {
    var content = '';
    var content_weighted = [];
    // For each form element, if the element objects name property isn't set,
    // set it, then render the element if access is permitted. While rendering
    // the elements, set them aside according to their widget weight so they
    // can be appended to the content string in the correct order later.
	var plus = 0;
    $.each(form.elements, function(name, element) {
        if (!element.name) { element.name = name; }
        if (drupalgap_form_element_access(element)) {
          if (element.is_field && element.field_info_instance.widget.weight) {
            if(element.field_info_instance.widget.weight < 0 ){
              if(plus == 0){
                plus = 1 - element.field_info_instance.widget.weight;
              }
              element.field_info_instance.widget.weight = element.field_info_instance.widget.weight + plus;
			}

            content_weighted[element.field_info_instance.widget.weight] =
              _drupalgap_form_render_element(form, element);
          }
          else {
            // Extract the bundle. Note, on comments the bundle is prefixed with
            // 'comment_node_' so we need to remove that to correctly map to the
            // potential extra fields data.
            var bundle = null;
            if (form.bundle) {
              bundle = form.bundle;
              if (
                form.entity_type == 'comment' &&
                form.bundle.indexOf('comment_node_') != -1
              ) { bundle = form.bundle.replace('comment_node_', ''); }
            }
            // This is not a field, if it has a weight in
            // field_info_extra_fields use it, otherwise just append it to the
            // content.
            if (
              form.entity_type && bundle &&
              typeof drupalgap.field_info_extra_fields[bundle][name] !==
                'undefined' &&
              typeof
                drupalgap.field_info_extra_fields[bundle][name].weight !==
                'undefined'
            ) {
              var weight = drupalgap.field_info_extra_fields[bundle][name].weight;
              if(weight < 0 ){
                if(plus == 0){
                  plus = 1 - weight;
                }
                weight = weight + plus;
              }
              content_weighted[weight] =
              _drupalgap_form_render_element(form, element);
            }
            else { content += _drupalgap_form_render_element(form, element); }
          }
        }
    });
    // Prepend the weighted elements to the content.
    if (!empty(content_weighted)) {
      content = content_weighted.join('\n') + content;
    }
    // Add any form buttons to the form elements html, if access to the button
    // is permitted.
    if (form.buttons && form.buttons.length != 0) {
      $.each(form.buttons, function(name, button) {
          if (drupalgap_form_element_access(button)) {
            var attributes = {
              type: 'button',
              id: drupalgap_form_get_element_id(name, form.id)
            };
            if (button.attributes) { $.extend(attributes, button.attributes); }
            content += '<button ' + drupalgap_attributes(attributes) + '">' +
              button.title +
            '</button>';
          }
      });
    }
    return content;
  }
  catch (error) { console.log('_drupalgap_form_render_elements - ' + error); }
}

I add following code to the function:


var plus = 0;
...
            if(element.field_info_instance.widget.weight < 0 ){
              if(plus == 0){
                plus = 1 - element.field_info_instance.widget.weight;
              }
              element.field_info_instance.widget.weight = element.field_info_instance.widget.weight + plus;
	    }
...
              if(weight < 0 ){
                if(plus == 0){
                  plus = 1 - weight;
                }
                weight = weight + plus;
              }

to make sure field's weight is > 0.

g089h515r806’s picture

Title: Field in node edit form does not display » Index of js array could not < 0
Status: Postponed (maintainer needs more info) » Active
tyler.frankenstein’s picture

Status: Active » Needs review

I believe this was fixed here long ago: https://github.com/signalpoint/DrupalGap/pull/369

g089h515r806’s picture

Yes, it is the same issue. I use DrupalGap 7.x-1.0-rc3 which does not contains the fix.

I try with DrupalGap 7.x-1.0-rc4 yesterday,I use cordova4.0.0, it does not work at all. There is no install document of DrupalGap 7.x-1.0-rc4.

g089h515r806’s picture

Status: Needs review » Closed (fixed)