The issue here is a bit complex, and has a few elements to it.
1) og_context tries to do some intelligent things by figuring out the event if you don't have an event specified. This works by putting in ?og_group_ref=NODEID basically with entityreference_prepopulate. But because these things are happening, it affects the ajax reloading of the og_vocabulary and view loading timeslots for a session (or bof or schedule_item)
2) The ajax callback for 'load more' or 'upload image' (or really anything) calls a path that doesn't start with 'node'. This means that og_context cannot find the event and doesn't know what to do with it. It clears the form out, which gets rebuilt on the backend. In some cases you'll loose your timeslot or track, in other cases it'll say 'an invalid option was selected' Either way, this is due to the ajax callbacks rebuilding the form.
3) There is different use cases around what an admin sees (admins can change the event on a node) vs what an end user sees (event selection is hidden). When hidden, that use case works pretty well because we just pass the form values around. When not hidden, we need to set the form[#state] for the element based on what the og_group_ref is set to. But alas, the visible function doesn't appear to work on initial loading.
$form['field_session_timeslot']['#states'] = array(
'visible' => array(
'xor',
array(':input[name="og_group_ref[und][0][default]"]' => array('!value' => '_none')),
// This sort of works, but would be better if it fired after
// the autocomplete. Note that this field is only available
// to administrators.
array(':input[name="og_group_ref[und][0][admin][0][target_id]"]' => array('empty' => FALSE)),
),
The '!value' => '_none' should mean that the field_session_timeslot appears whenever the value for og_group_ref is not _none, but this doesn't work on initial loading of the form, even though og_group_ref is not set to none if you have an event specified.
So yah, its annoying bug. It'll involve patching og_context, creating a new og_context hander, patching og_vocab (probably), and changing around cod_Session and cod_schedule.
This is the last Beta2 blocker.
Comments
Comment #1
japerryretitling for accuracy.
Comment #4
japerryFixed! Added some patches to the make file to patch entityreference_prepopulate, as well as created a new views handler to fix the entityreference validate query from responding with illegal operations.
Comment #6
iamEAP commentedSorry to hijack the thread... Keeping this closed, just adding some notes for people coming here via Google.
This definitely applies to older, alpha builds of COD... But may apply to newer builds. It may have been resolved by the commits above, I don't know. In any event...
If you're getting an "illegal choice" error on your session timeslot field (specifically, after someone triggers an AJAX form submit via a file upload field, or by adding more speakers, etc)... The root cause is that the cod_session_timeslot View, which is used to define the available options for the entity reference field, attempts to pull contextual filter values for the node ID and OG reference group from the content URL and OG context (respectively).
Because the form submit is triggered and handled in an AJAX context (at a path like
file/ajaxorsystem/ajax), the View is unable to get the appropriate values from context, and thus returns an empty list of options for the timeslot field. The submitted value (whatever's selected on the node) is validated against the empty option set, and fails.There are basically two ways to handle this... The first is to fiddle with the contextual filters in the cod_session_timeslot View to be able to pull the necessary values correctly (there may be patches for OG to handle the OG context issue; the node ID would probably require custom code or use of PHP filter). The second, and the route I decided to take, was to manually repopulate the session timeslot options in a form alter. Sample code below:
Comment #7
shaiss commentedAnyone know if this has been fixed in the latest COD distro?
Comment #8
japerryYes, it should be. We're using the patch from #1970320: Doesn't work with file entity file/add path and it seems to be working well.