All my text fields with values grabbed with drupalgap_field_info_instances_add_to_form are displaying as empty. Let me try to explain this bug (?) I'm experiencing.

This is on a custom entity form so not sure if it's true with other forms but I have fields on my custom entity.

The following in drupalgap_field_info_instances_add_to_form sets the value:

                form.elements[name][language][delta] = {
                  'value': default_value
                };

Then in _drupalgap_form_render_element the following sets the attribute value:

       // If there wasn't a default value provided, set one. Then set the
        // default value into the variables' attributes.
        if (!item.default_value) { item.default_value = ''; }
        variables.attributes.value = item.default_value;

This leads to no value being set in my text fields.

Should the fix be adding a default value to drupalgap_field_info_instances_add_to_form? Might work on this.

Comments

lifeinpoetry’s picture

Issue summary: View changes
lifeinpoetry’s picture

Issue summary: View changes
lifeinpoetry’s picture

Title: Text Fields with Values Set by drupalgap_field_info_instances_add_to_form Empty » Text fields with values set by drupalgap_field_info_instances_add_to_form are empty
tyler.frankenstein’s picture

Status: Active » Needs work

Hmmm, this is interesting. I haven't experienced this problem, but I see what you are saying. The value can/will definitely be lost in some instances. Feel free to fork the SDK and submit a pull request if you have a fix. Otherwise, I'll take a look at this ASAP.

lifeinpoetry’s picture

I don't know if this makes a difference but the custom entity form I'm talking about is one for Profile2. It gets the values via a module I made for DrupalGap, this module interacts with Services Entity API since standard DrupalGap/jDrupal didn't seem to support getting Profile2 fields/values.

tyler.frankenstein’s picture

Thanks for pointing this out. I think it will be a good idea if DrupalGap becomes dependant on the Services Entity API (and jDrupal as well), so we can support custom entity types. This will be quite the undertaking, but very beneficial in the long run.

tyler.frankenstein’s picture

tyler.frankenstein’s picture

Status: Needs work » Closed (fixed)

This has been fixed, grab the latest dev snapshot of the SDK for the fix:

www.drupalgap.org/download

Thank you @lifeinpoetry for your help isolating the issue.