I implemented a search in index action, but when I click on the search button throws me this exception:
This is the code to search in index view:
<?php
echo $this->Form->create(null, ['valueSources' => 'query']);
echo $this->Form->control('search', ['label' => 'Buscar', 'placeholder' => 'Wildcards: * and ?']);
echo $this->Form->control('profile_id', ['label' => 'Perfil', 'empty' => '- Seleccione un perfil -', 'options' => $profiles]);
echo $this->Form->button(__('Buscar'), ['class' => 'btn btn-primary']);
if (!empty($_isSearch)) {
echo ' ';
echo $this->Html->link(__('Reset'), ['action' => 'index', '?' => array_intersect_key($this->request->getQuery(), array_flip(['sort', 'direction']))], ['class' => 'btn btn-default']);
}
echo $this->Form->end();
?>
And this is the code to enable search in UsersTable.php:
$this->addBehavior('Search.Search');
$this->searchManager()
->value('username')
->value('email')
->value('profile_id')
->add('search', 'Search.Like', [
'before' => true,
'after' => true,
'fieldMode' => 'OR',
'comparison' => 'LIKE',
'wildcardAny' => '*',
'wildcardOne' => '?',
'fields' => ['username','email','profile_id'],
]);
How can I solve this issue?