I am a newbie trying to create a simple (in theory) CRUD application using symfony 1.4. I am trying to use filters on my index page so that the user can select the records thay want to view rather than the entire list.
I followed the instructions I found here http://www.michelsalib.com/2010/10/how-to-use-filters-on-custom-fields (although I am not using custom fields, only ones that appear in the table and are listed in the Base--FormFilter class). This works perfectly for all my fields except the one that is a foreign key.
When I try to filter on any of these values, the validation fails.
The filter widget is:
new sfWidgetFormDoctrineChoice(array(
'model' => $this->getRelatedModelName('EatLocations'),
'add_empty' => true))
and the validator is:
new sfValidatorDoctrineChoice(array(
'required' => false,
'model' => $this->getRelatedModelName('EatLocations'),
'column' => 'loc_abbrev')
I thought the problem was that the validator was pointing to the wrong column, but when I set ‘column’=>”location_id’ (the column the foreign key points to) I get this error:
You must define a “addEaUnitColumnQuery” method to be able to filter with the “ea_unit” field.
I have seen some examples of how to write this method, but they seem overly complicated, and I’m not sure how to apply this to my table. Does anyone know if there is a simpler way to solve this?
SOLVED:
The auto-generated code in the Base class specified the column, so I had to override it.
I solved the probelm by setting the column in the validator to ‘location_id’ and then
writing the following function…