TransWikia.com

How to allow multiple values in a single value textfield

Drupal Answers Asked on October 26, 2021

I am using views_conditional module for Drupal 7 and would like to use a comma separated array (i think this is called an array?) of values in the "This value" textfield.

For example, I would like to add a views conditional field that checks for:

If this field…
[type] == Content Type

Is…
Contains

This value…
Apples, (or) Oranges, (or) Bananas

As it is right now, (unless I am missing something) I would need to add 3 separate conditional field. One for each content type (apples, oranges, and bananas) though they are all executing the same function.

(I think) The current definition for the value field is:

$form['equalto'] = array(
  '#type' => 'textfield',
  '#title' => t('This value'),
  '#description' => t('Input a value to compare the field against.  Replacement variables may be used'),
  '#default_value' => $this->options['equalto'],
);

I also think the logic for the "Is…" operator in this use case would technically need to be something like "Contains Any".

(I think) The "Contains" function is defined here:

      // Contains
  case 7:
    if (mb_stripos($r, $equalto) !== FALSE) {
      return $then;
    }
    else {
      return $or;
    }
    break;

Is there a way to simply write a couple of hooks to alter the form, or would i need a full blown module patch?

Any help or pointers would be greatly appreciated! I am pretty new to backend code. I also posted a support request at Drupal.org

One Answer

There is a patch for this for anyone else looking for a solution.

https://www.drupal.org/project/views_conditional/issues/2690167

Answered by tonytheferg on October 26, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP