Hi,
I want to have a multi filter search for restaurants (to filter the cuisine, like italien, fish, tapas and so on). Ive tried to adapt this solution: Is it possible to create multi filter search based on filterBy? but it doesnt work, I receive an error: “preg_quote() expects parameter 1 to be string, array given”
My template is this:
<form>
<select name="kueche[]" multiple>
<option value="fisch">Fisch</option>
<option value="spanisch">Spanisch</option>
<option value="tapas">Tapas</option>
<option value="italienisch">Italienisch / Pizza</option>
</select>
<input type="submit" value="Search">
</form>
<?php foreach($restaurants as $restaurant): ?>
<p><strong><?= $restaurant->title() ?></strong> - <?= $restaurant->kueche() ?><br/>
<?= $restaurant->strasse() ?>, <?= $restaurant->postleitzahl() ?>, <?= $restaurant->parent()->title() ?><br/>
Tel.: <?= $restaurant->telefonnummer() ?></p>
<?php endforeach ?>
And my controller is this:
return function($site, $pages, $page) {
// get all restaurants and add pagination
$restaurants = $site->index()->filterBy('intendedTemplate', 'restaurant')->paginate(50);
if($query_kueche = $_GET['kueche']) {
$restaurants = $restaurants->search($query_kueche, 'kueche');
}
// create a shortcut for pagination
$pagination = $restaurants->pagination();
// pass $restaurants and $pagination to the template
return compact('restaurants', 'query_kueche', 'pagination');
};
It has something to do with the multiselect, right, because its an array then? But I thought the solution from the other thread should working with multiselect?