Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment #1
lifeinpoetry CreditAttribution: lifeinpoetry commentedComment #2
lifeinpoetry CreditAttribution: lifeinpoetry commentedComment #3
lifeinpoetry CreditAttribution: lifeinpoetry commentedComment #4
tyler.frankenstein CreditAttribution: tyler.frankenstein commentedHmmm, 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.
Comment #5
lifeinpoetry CreditAttribution: lifeinpoetry commentedI 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.
Comment #6
tyler.frankenstein CreditAttribution: tyler.frankenstein commentedThanks 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.
Comment #7
tyler.frankenstein CreditAttribution: tyler.frankenstein commentedComment #8
tyler.frankenstein CreditAttribution: tyler.frankenstein commentedThis 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.