I'm trying to set up the FriendsOfCake Search plugin (https://github.com/FriendsOfCake/search) on CakePHP 3.1
I followed the instructions in the docs and set up a form in my index.ctp and try to filter only by title with a form.
But it seems like the forms post data is not processed by the method afterwards. There are no search parameters showing up in the URL. If I type in the URL manually like: /paintings/index?title=blob it does filter correctly. So the plugin itself is working, I guess the problem is with the form, because after pressing the Submit button it just does nothing.
I'm new to CakePHP and have only limited knowledge so far. The informations in the Plugin documentation are very basic, so I'm not sure if it might assume some more settings without mentioning them?!
If I use the form to search for "blob" for example, the page is loading again without filtering and in the DebugKit it says: Post Data -- title blob.....But: no querystring data (if that means anything..)
Can anybody help me figure out, what I'm doing wrong? I think there is something missing in my Controller or in the form settings in the view but I can't figure out what. Thanks for any help!
Here is my setup:
class PaintingsTable extends Table
{
public function searchConfiguration()
{
$search = new Manager($this);
$search->like('title', [
'field' => $this->aliasField('title')
]);
return $search;
}
class PaintingsController extends AppController
{
public function initialize()
{
parent::initialize();
if ($this->request->action === 'index') {
$this->loadComponent('Search.Prg');
}
}
public function index()
{
$query = $this->Paintings
->find('search',
$this->Paintings->filterParams($this->request->query))
->contain(['Artists']);
$this->set('paintings', $this->paginate($query));
$this->set('_serialize', ['paintings']);
}
}
In Paintings - index.ctp:
<?= $this->Form->create(); ?>
<?= $this->Form->input('title') ?>
<?= $this->Form->button('Filter', ['type' => 'submit']) ?>
<?= $this->Html->link('Reset', ['action' => 'index']) ?>
<?= $this->Form->end()?>