Problem/Motivation
When using entity_field_value plugin to limit visibility of a pane on a taxonomy field with Hierarchical select widget, we found an issue that is causing visibility rule settings not to be set and saved.
This is truly widget dependent, switching back to select list widget on this taxonomy field helped to resolve the issue, but it's not an option as we need to use hierarchical select widget on node edit page.
It looks like the problem is in this snippet:
$form_state = array(
'display' => &$this->display,
'pane' => &$pane,
'ajax' => TRUE,
'title' => t('Configure visibility rule for !subtype_title', array('!subtype_title' => $subtype['title'])),
'test' => &$pane->access['plugins'][$id],
'plugin' => ctools_get_access_plugin($pane->access['plugins'][$id]['name']),
'url' => url($url, array('absolute' => TRUE)),
);
$output = ctools_modal_form_wrapper('panels_edit_configure_access_test_form', $form_state);
While $form_state['display'] should have a reference to $this->display and modifying $form_state['display'] should be propagated to $this->display (which is used for saving display settings later, this does not happen sometimes.
The reason for this is $form_state is passed by reference, but under certain circumstances it is not the same object when it is returned into this scope. This happens primarily on form_get_cache, when $form_state is being rebuilt when form used on visibility settings widget uses AJAX and triggers rebuild.
Proposed resolution
I propose to make sure we assign back the $form_state['display'] to $this->display as this is critical to keep settings saved.
Remaining tasks
Provide a patch
User interface changes
None
API changes
None
Data model changes
None
Comment | File | Size | Author |
---|---|---|---|
#3 | panels-broken_visibility_settings-ajax-2605094-3.patch | 820 bytes | asgorobets |
#2 | panels-broken_visibility_settings-ajax-2605094-1.patch | 776 bytes | asgorobets |
Comments
Comment #2
asgorobets CreditAttribution: asgorobets at FFW commentedAdding a patch
Comment #3
asgorobets CreditAttribution: asgorobets at FFW commentedouch, patch in #2 was applied to a different form, and it was also incomplete.
Attaching a corrected patch, that applies to 'panels_edit_configure_access_test_form' rather than 'panels_edit_configure_access_settings_form'.
Also had to restore $pane variable reference as well, as Delete action was not working properly either when form is retrieved from cache.
Comment #4
BR0kENComment #5
japerryI don't believe this is actually RTBC'd yet
Comment #6
BR0kENOf course you don't, @jappery. But the same problems exists at whole
panels_renderer_editor
object.Comment #7
BR0kENNo need to go far away, let's look at the
ajax_style_settings
method.This code from a form submit callback from a custom module (pay attention on @todo):
This can be easily fixed by adding
$this->cache = $form_state['renderer']->cache;
beforeif (isset($this->cache->style)) {
at theajax_style_settings
method.Need to debug to know why this happens. Also, constructions like this
'renderer' => &$this,
, do not have any sense, because all objects in PHP are passed by reference.