Multi filter search


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:

			  <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>
			  <input type="submit" value="Search">

		  <?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?

No, the example you are referencing, doesn’t use a multiselect. And yes, what you get from your multi select, is an array and the query can only be a string. But you could convert your array to a string using implode():

$string = implode(' ', get('kueche'));