I’ve got content-type with two double-valued fields field_price1 and field_price2. There are interior names. I’ve also got page view (its machine name is search) displaying contents. I’ve got search with some filters. I decided to create one exposed filter connected with field_price1 field with between operator. Second filter isn’t exposed and it is connected with field_price2 field.
I want to display content in the view only if its field_price1 or field_price2 is between values given by user in the search. So that, filter for field_price2 field has to inherit the value from the first exposed filter. I created custom module named customSearch with code posted below in customSearch.module file.
function customSearch_views_pre_view(&$view) { if ($view->name == 'search') { $filters = $view->display_handler->get_option('filters'); $filters['field_price2_value']['value']['min'] = $view->exposed_input['field_price1_value']['min']; $filters['field_price2_value']['value']['max'] = $view->exposed_input['field_price1_value']['max']; $view->display_handler->override_option('filters', $filters); } }
Unforntunately, I’ve got errors.
Notice: Undefined property: view::$exposed_input in customSearch_views_pre_view() in line
$filters['field_price2_value']['value']['min'] = $view->exposed_input['field_price1_value']['min'];
Notice: Undefined property: view::$exposed_input in customSearch_views_pre_view() in line `$filters[‘field_price2_value’][‘value’][‘max’] = $view->exposed_input[‘field_price1_value’][‘max’];
Could someone help me, please?
Sponsored by SupremePR