Open mkinnan opened 8 years ago
To clarify, the default value that gets set is for the user while in the app or in emulator. It does not appear to be set globally.
I can see the default value has been set when the node create form is viewed in console.log.
Here's a snippet from my crude work around that has passed my emulator testing ...
if (form.id == 'node_edit' && form.bundle == 'discussion') {
if (_GET('dt') == 1) {
console.log('-- discussion type: group --');
form.elements['group_ref']['und']['0'].default_value = _GET('gnid');
form.elements['field_event_ref']['und']['0'].default_value = '';
}
if (_GET('dt') == 2) {
console.log('-- discussion type: event --');
form.elements['group_ref']['und']['0'].default_value = _GET('gnid');
form.elements['field_event_ref']['und']['0'].default_value = _GET('enid');
}
@mkinnan This seems like an OK approach. When you set the default_value
, if you were to check if it is a new node, then you could skip setting the value if that's what you need. Please clarify, thanks.
@signalpoint The default_value
isn't really a default value since that value changes. The problem is that if a user creates a discussion on an event in a group, the discussion gets referenced by two entity fields (one for the group, and one for the event). If the user then creates a discussion in a group, the discussion should only be referenced by the group entity field ... but the entity reference field for events has the default value set when the user created that discussion on an event. Thus the group discussion gets erroneously referenced to an event.
Does that clarify what is happening with default value?
The only way I can set an entity reference field is doig
However, by doing
default_value
it sets an actual default value so all future nodes that have no reference get a value of that default_value previously set. I've tried doingvalue
but that doesn't work.I don't think
default_value
is the right thing to do, but it is the only thing that works.Thoughts?
https://github.com/signalpoint/DrupalGap/issues/704 https://github.com/signalpoint/DrupalGap/issues/709