1

I have created a exposed fulltext search filter with the searched fields["tile", "Description","Keywords"]. This brings the widget to the form as a textfield, which searches the input for all the three fields.

I'm trying to bring the searched fields["title","Description","Keywords"] to the form as a radio button list, So that the user can type the input and select under what field to refine the result.

Any help really appreciated!

1 Answer 1

0

I found a work around for this. We can create a radio button list in hook_form_alter() having the searched fields. Using hook_search_api_views_query_alter(), we can alter the fields that are passed in the $query object, so that the result set is returned only for the field that is been searched.

function MYMODULE_search_api_views_query_alter(&$view, &$query) {
    if(isset($_GET['your_field_name'])) {
        switch($_GET['your_field_name']) {
            case 'field1':              
                $fields = $query->getFields();
                $fields = array( 0 => 'field1_value');          
                $query->fields($fields);
            break;
            .....
            .....
          }
        }
      } 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.