As it currently stands, views_handler_filter_in_operator only supplies default Yes/No values, and requires module writers to subclass it in order to provide their own options generator.

This is done in order to prevent storage of such values in the database. An alternative is to provide a way to simply pass a callback generating these values, by declaring its name as an options callback parameter in the field definition, which can either be a string containing the name of a function, or a (class,method) array, as used by call_user_func().

The suggested patch includes this.

CommentFileSizeAuthor
#3 in_operator.patch1.38 KBfgm
#1 in_operator.patch1.31 KBfgm
views.patch1.22 KBfgm

Comments

fgm’s picture

StatusFileSize
new1.31 KB

Eeek, wrong patch submitted.

dww’s picture

Status: Needs review » Needs work

cool, thanks. in principle, i support this feature. in practice, do we really need to do this in a single line? ;)

+    $this->value_options = (isset($this->definition['options callback']) && is_callable($callback = $this->definition['options callback']))
+      ? call_user_func($callback) : array(t('Yes'), t('No'));

I mean, I can read it, and I'm sure it works, but geeze... can't we split this up into a few more lines to make the logic of it more self evident? ;)

Maybe Earl likes this kind of thing, but personally, I've never understood the appeal of "it's a tiny patch -- only 1 line! (with a ternary operator and a side-effect assignment nested inside a conditional clause)..."

fgm’s picture

Status: Needs work » Needs review
StatusFileSize
new1.38 KB

OK, back to my original version, then. Maybe my APL background shows too much :-)

merlinofchaos’s picture

Status: Needs review » Fixed

Commited to 2.x and 3.x

Status: Fixed » Closed (fixed)

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