I am building a number of node template variants based on a list field on the node where the content admin can choose which layout they would like their page to have.

I've chosen this field under "selection rules" for each variant and chosen the appropriate value for the variant. After changing the value for this field, if I click the configure settings gear for the item, the values are presented with the default value rather than the value I selected for the active variant. If I change the value again and click "update and save", when I return to the "selection rules" tab and click on the configure settings gear, yet again the default value is selected instead of the value I had chosen and saved.

The result is that changing the value for this field on the node does not result in the appropriate page variant being applied to that node page.

Oddly enough, the export code outputs the correct value for this setting:

$handler->conf = array(
    'title' => 'T3 Interior Template Three',
    'no_blocks' => 0,
    'pipeline' => 'standard',
    'css_id' => 'tfa-template-three',
    'css' => '',
    'contexts' => array(),
    'relationships' => array(),
    'access' => array(
      'plugins' => array(
        0 => array(
          //Layout Setting
          'name' => 'entity_field_value:node:page:field_page_layout',
          'settings' => array(
            'field_page_layout' => array(
              'und' => array(
                0 => array(
                  'value' => 'three',
                ),
              ),
            ),
            'field_page_layout_value' => 'three',
          ),
          'context' => 'argument_entity_id:node_1',
          'not' => FALSE,
        ),
        1 => array(
          'name' => 'node_type',
          'settings' => array(
            'type' => array(
              'page' => 'page',
            ),
          ),
          'context' => 'argument_entity_id:node_1',
          'not' => FALSE,
        ),
      ),
      'logic' => 'and',
    ),
  );

I've tested this on a clean install of Drupal and was able to recreate the issue.

Steps to reproduce:

  • Add a list (text) field with radios widget to any node type
  • provide 2-3 options for that field
  • Enable the Node Template page in Page Manager
  • Create a new variant
  • Under selection rules, choose the new field you created from the drop-down list. configure it to use any one value.
  • choose the "all criteria must pass option"
  • Save the variant
  • Create a test node with the same value for the option field as your page variant and notice that the panel is not applied to that node.
  • Edit the variant. click the "configure" gear next to you field selection rule and notice that the default option is selected instead of the option previously specified.

Let me know if I can provide any more information. The entirety of the variant export code is attached.

Files: 
CommentFileSizeAuthor
#2 ctools-field_access_plugin_ignoring_selected_value-1601062-1.patch1.12 KBTresler
PASSED: [[SimpleTest]]: [MySQL] 24 pass(es).
[ View ]
field_access_bug_example_page.txt6.09 KBsheena_d

Comments

This took a bit of figuring out... The bracketing is incorrect in entity_field_value.inc 102:113

  // Need more logic here to handle compound fields.
  foreach ($columns as $column) {
    if (isset($conf[$column]) && is_array($conf[$column])) {
      foreach ($conf[$column] as $delta => $conf_value) {
        if (is_numeric($delta) && is_array($conf_value)) {
          $form['settings'][$field_name][LANGUAGE_NONE][$delta]['value']['#default_value'] = $conf_value['value'];
        }
        else {
          $form['settings'][$field_name][LANGUAGE_NONE]['#default_value'] = $conf[$column];
        }
      }
    }
  }
  return $form;

Should be:

  // Need more logic here to handle compound fields.
  foreach ($columns as $column) {
    if (isset($conf[$column]) && is_array($conf[$column])) {
      foreach ($conf[$column] as $delta => $conf_value) {
        if (is_numeric($delta) && is_array($conf_value)) {
          $form['settings'][$field_name][LANGUAGE_NONE][$delta]['value']['#default_value'] = $conf_value['value'];
        }
      }
    }
    else {
      $form['settings'][$field_name][LANGUAGE_NONE]['#default_value'] = $conf[$column];
    }
  }
  return $form;

Patch coming in shortly.

Assigned:Unassigned» Tresler
Status:Active» Needs review
StatusFileSize
new1.12 KB
PASSED: [[SimpleTest]]: [MySQL] 24 pass(es).
[ View ]

Ok - patch attached.

Version:7.x-1.0» 7.x-1.x-dev
Priority:Normal» Major
Status:Needs review» Reviewed & tested by the community

Thanx a lot, this really useful and major because could cause a data loss because select-list always resets

patch applies cleanly and fixes a edit form.

Related issues #1558708: Ctools bug in term rule ('tid equals') in Panels Selection rules #1435426: Notices thrown when using visibility rules on hidden fields
They are about summary is not displayed

Just curious, does anything else need to happen to get this applied? Do I need to send a merge request of something?

I have the same problem. Used patch #2 and now problem desapear. I think this is very major bug!!!! So please commit it as soon as possible.

Status:Reviewed & tested by the community» Needs work

Actually the problem in a way that ctools stores config values, so first we need to fix form and submit hanler, see details in #1630820-15: entity_field_value is completely broken

Status:Needs work» Reviewed & tested by the community

Suppose this change makes sense as stand-alone

PS: Fix for false positives #1630820-24: entity_field_value is completely broken

Status:Reviewed & tested by the community» Fixed

Committed and pushed.

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.