You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Aug 1, 2024. It is now read-only.
Now, I would like create searching using LexikFormFilterBuilder, so I create something like this.
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('name', 'text', array());
$builder->add('price', 'text', array());
$builder->add('type', 'text', array());
}
And this works and is OK.
This renders 3 inputs in template. But I would like render only one field( search fields ), which will be create 'OR' condition on name, price, type columns. It is possible ?
The text was updated successfully, but these errors were encountered:
Yes that's possible. You don't have to add the fields you currently have, but should ad a search field that isn't mapped to the entity, and has a custom apply_filter:
->add('search', TextFilterType::class, array(
'apply_filter' => function (ORMQuery$filterBuilder, $field, $values) {
if (!empty($values['value'])) {
$filterBuilder->getQueryBuilder()
->orWhere("p.name LIKE '%:value%'")
->orWhere("p.price LIKE '%:value%'")
->orWhere("p.type LIKE '%:value%'")
->setParameter('value', $values['value'])
;
}
},
'mapped' => false,
))
Hi
I have entity CustomerMachine.php
Now, I would like create searching using LexikFormFilterBuilder, so I create something like this.
And this works and is OK.
This renders 3 inputs in template. But I would like render only one field( search fields ), which will be create 'OR' condition on name, price, type columns. It is possible ?
The text was updated successfully, but these errors were encountered: