Hey mattsister ,

I've had the same issue, and there's an easy fix.
The reason is that text fields really submit 2 values, the text
content and the "is_empty" flag, so they arrive as an array.
When you switch that to a select, it arrives as a single value, and
won't be processed correctly.

The solution is to override the getFields() function of your filter
form like so:
public function getFields()
{
    $fields = parent::getFields();
    $fields["mese"] = "ForeignKey";
    return $fields;
}


And that's it. Done.
Hope it helps,
Daniel




On Aug 27, 2:21 pm, mattsister <matt...@gmail.com> wrote:
> I have a TINYINT column in my db that represent the month. In the
> filter section of my backend I want a select instead of an input text.
> So I made this in my filter class:
>
> $mese_choices = array(
>       '' => 'Tutti i mesi',
>       1  => 'Gennaio',
>       2  => 'Febbraio',
>       3  => 'Marzo',
>       4  => 'Aprile',
>       5  => 'Maggio',
>       6  => 'Giugno',
>       7  => 'Luglio',
>       8  => 'Agosto',
>       9  => 'Settembre',
>       10 => 'Ottobre',
>       11 => 'Novembre',
>       12 => 'Dicembre'
>     );
>
>     $this->setWidget('mese', new sfWidgetFormChoice(array('choices' =>
> $mese_choices)));
>     $this->setValidator('mese', new sfValidatorChoice(array('choices'
> => array_keys($mese_choices))));
>
> Everything seems fine, when I choose a month from the dropdown and
> press "filter" no errors pop up. But for some strange reason the list
> is not filtered. The dropdown is completely ignored. I've inspected
> the queries generated and anything related to the month column shows
> up...
>
> Any idea?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to 
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to