Download & Extend

Showing operator field before filter field

Project:Views Filter Block
Version:5.x-1.4
Component:Code
Category:support request
Priority:normal
Assigned:Unassigned
Status:active

Issue Summary

Hi,

First let me thank you for this great module, it already helped me a lot.

I'm having a problem with the order of the operator and filter field. I've created a view with a filter based on the categories of a node. When using the regular filters on a view, first the operator field ("is one of", "is all of", "is none of") is shown, followed by the list of categories (see without_block.png).
With the Views Filter Block module however, the list of categories is shown before the operator field (see with_block.png). As a result the purpose of the operator field isn't clear to the user.

I've already looked into the code and I've tracked it down to the views_filterblock_get_form('views_filterblock', $view); call in the _views_filterblock_block($delta) function. This results in a successive call of drupal_get_form, drupal_render_form and finally drupal_render.
According to the documentation of drupal this function executes the following code

if (!isset($elements['#sorted'])) {
    uasort($elements, "_element_sort");
}

The uasort function sorts every element of the form. As a result the 'filter$delta' field is listed before the 'op$delta' field.

Any ideas on how I can get around this sorting? I've tried by setting $form['#sorted'] = true; in the views_filterblock(view) function, but apparently this attribute is removed by the drupal_process_form() call in drupal_get_form().

Hopes this makes any sense. Thanks.

AttachmentSize
with_block.png8.74 KB
without_block.png7.18 KB