Not sure if this is CTools territory as this thread looks quite similar: http://drupal.org/node/1101432, but:

On a cutstom content type I have a text field, type=list, and values are set up using key|label format and only a single value is permitted (radio select list)

On a node-view panels page I'm trying to set up a selection rule pair:
- select node where type = bar
- select where node:field_foo value = (tick on select list)

I select the desired value, save the selection rule, and: an empty rule (no value for the field) is returned.

Thinking there might be an issue with having two rules, I deleted the node=type rule, leaving only the rule that seeks to select based on a value in the list field. Still get an empty value returned (see attached).

Clues or related issue queues?

Thanks in advance!

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

boabjohn’s picture

Can anyone at least clarify if this looks like a Panels or CTools issue?
Thanks.

rogical’s picture

you can try to use php to get compare field value as temp solution.

jennypanighetti’s picture

Issue summary: View changes

I am surprised this issue hasn't been resolved yet, as it's STILL an issue two years later, for me at least.

I have a node field I'm using in Selection Rules. I select the relevant choices from the multiselect box. I save. NOTHING shows up after "tid equals", and when I go back to configure it, the selections are not visibly saved!!

It actually changes the selection properly, but nothing is visible, which makes configuration very difficult.

boabjohn’s picture

G'Day @jenstechs, sorry to see this is still an issue. To be honest, I can't remember what I did to route around the problem...certainly no code was involved, so I probably just came up with an alternatively approach that avoided this issue.
It may well be a bug, given that at least one other person has experienced it!
Maybe changing the status will get some attention. Panels is a big beast though, and this is a relatively obscure problem, I guess.
Wish I could be of more specific help to you...the Drupal community is very good, so best wishes for a successful resolution!
Kind regards,
JB

neoxavier’s picture

Version: 7.x-3.3 » 7.x-3.x-dev
Category: Support request » Bug report

I guess this is a bug and I can confirm the issue.

I get this warning as well when trying to save the criteria
Warning: Illegal offset type in isset or empty in list_field_formatter_view() (line 467 of /home/projects/d7/modules/field/modules/list/list.module).
Warning: strlen() expects parameter 1 to be string, array given in drupal_validate_utf8() (line 1601 of /home/projects/d7/includes/bootstrap.inc).
Warning: htmlspecialchars() expects parameter 1 to be string, array given in check_plain() (line 1573 of /home/projects/d7/includes/bootstrap.inc).
Warning: Illegal offset type in isset or empty in list_field_formatter_view() (line 467 of /home/projects/d7/modules/field/modules/list/list.module).
Warning: strlen() expects parameter 1 to be string, array given in drupal_validate_utf8() (line 1601 of /home/projects/d7/includes/bootstrap.inc).
Warning: htmlspecialchars() expects parameter 1 to be string, array given in check_plain() (line 1573 of /home/projects/d7/includes/bootstrap.inc).

neoxavier’s picture

I guess this is more ctools related problem

neoxavier’s picture

Project: Panels » Ctools
Version: 7.x-3.x-dev »

I guess I will move it to ctools' issue queue from panels' issue queue

neoxavier’s picture

Project: Ctools » Chaos Tool Suite (ctools)
Version: » 7.x-1.x-dev

I moved it from panels' issue queue to ctools' issue queue

KeyboardCowboy’s picture

I am running into the same issue, but with a multi-cardinality text list field. I've found that the selection rule setting is being stored properly, but those default settings are not being rendered properly in the ctools summary on the variant or when editing the selection rules item config.

The errors are coming from the $items var being formatted incorrectly in list_field_formatter_view when coming from ctools.

/**
 * Implements hook_field_formatter_view().
 */
function list_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
  $element = array();

  switch ($display['type']) {
    case 'list_default':
      $allowed_values = list_allowed_values($field, $instance, $entity_type, $entity);
      foreach ($items as $delta => $item) {
        if (isset($allowed_values[$item['value']])) {
          $output = field_filter_xss($allowed_values[$item['value']]);
        }
        else {
          // If no match was found in allowed values, fall back to the key.
          $output = field_filter_xss($item['value']);
        }
        $element[$delta] = array('#markup' => $output);
      }
      break;

    case 'list_key':
      foreach ($items as $delta => $item) {
        $element[$delta] = array('#markup' => field_filter_xss($item['value']));
      }
      break;
  }

  return $element;
}

In the two attached images, one shows the $items array as passed in from ctools, and the other is how the $items array is formatted in a standard node view.

You can see that only one item is selected in the ctools image, which is the correct value. I want this selection rule to trigger the variant ONLY IF this value is checked. So the value is being stored correctly, but not evaluated correctly in ctools.

This code snippet shows the settings are saved:

        2 => array(
          'name' => 'entity_field_value:node:tv_show:field_show_ms_base_menu',
          'settings' => array(
            'field_show_ms_base_menu' => array(
              'und' => array(
                0 => array(
                  'value' => 'episodes',
                ),
              ),
            ),
            'field_show_ms_base_menu_value' => array(
              'episodes' => 'episodes',
              'photos' => NULL,
              'videos' => NULL,
              'cast' => NULL,
            ),
          ),
          'context' => 'argument_entity_id:node_1',
          'not' => FALSE,
        ),

The issue is that the ctools $items array needs to be formatted as the list view function expects it to.

I don't have time to dig too deep into this issue at the moment, but I hope this can give someone a better start.