In my filter, a field's behaviour is to search in the DB table for a row that has the value of the field equal
to the value provided in filtering form. I'd like to change its behavior to search in DB table for a row/rows that have field value matching to that provided in the form(%LIKE%
).
I know it can be done by adding a addFieldnameColumnQuery
method to the filter class but What I want to know is, is there another way?
The field happens to be a foreign key and I want it to work like a normal text field.
UPDATE: this was a silly mistake. I needed to assign a sfWidgetFormFilterInput to the widgetSchema but I was using sfWidgetFormInput which was causing it to look for equality instead of matching.
I never hear about another way... have a look at
sfFormFilterDoctrine
class located inlib\vendor\symfony\lib\plugins\sfDoctrinePlugin\lib\form
to understand how this system works and how you can write youraddFieldnameColumnQuery
UPDATE To change just the filter behaviour for a field, say
myfield
, from foreign key to normal text you can simply set the widget and overridegetFields()
inMymoduleFormFilter
class with some code like this:Instead if you define a field to search in a joined table you have yet to set the widget according to the field name you wrote in generator.yml
and finally add
addMyfieldColumnQuery(Doctrine_Query $query, $field, $values)
with inside the join and where code. Sorry, no snippet for this because I use Propel.