Instead of modifying each filter class, i only modified
BaseFormFilterDoctrine
abstract class BaseFormFilterDoctrine extends sfFormFilterDoctrine
{
public function setup()
{
foreach($this as $name => $field)
{
if($field->getWidget() instanceof sfWidgetFormFilterDate)
{
$field->getWidget()->setOption('from_date', new
sfWidgetFormMooToolsDate());
$field->getWidget()->setOption('to_date', new
sfWidgetFormMooToolsDate());
$field->getWidget()->setOption('template', 'from
%from_date% to
%to_date%');
$field->getWidget()->setOption('filter_template',
'%date_range%
%empty_checkbox% %empty_label%');
}
}
parent::setup();
}
}
If you notice, I used sfWidgetFormMooToolsDate which extends
sfWidgetFormInput(yes you can simply replace it with
sfWidgetFormInput). It's basically a date picker widget I made. The
widget uses this datepicker
http://www.monkeyphysics.com/mootools/script/2/datepicker
if someone is interested with this widget, email me.
Oh, this method is also applicable with other generated form.
On Sep 8, 1:38 am, Stefano <[email protected]> wrote:
> Hi, to all.
>
> I'm customizing an Admin generated FormFilter with a Date Range.
>
> I redefined the widget using two sfWidgetFormFilterInput for the
> "from" and "to" fields, since I don't like the standard widgets used
> for month, day and year.
>
> It works, but when the page with the filtered records is displayed the
> "from" and "to" fields are empty, so the User has no visual feedback
> of the applied filter.
>
> How can I retrieve the value and set it again before the form is
> redisplayed?
>
> TIA
>
> Stefano
>
> class ListinoFormFilter extends BaseListinoFormFilter
> {
> public function configure()
> {
> parent::setup();
>
> $this->widgetSchema['DataInizioValidita'] = new
> sfWidgetFormFilterDate(array('from_date' => new
> sfWidgetFormFilterInput(array('with_empty' => false),
>
> array('size' => 10, 'maxlength' => 10,
>
> 'class' => 'campoData')),
>
> 'to_date' => new sfWidgetFormFilterInput(array('with_empty' =>
> false),
>
> array('size' => 10, 'maxlength' => 10,
>
> 'class' => 'campoData')),
>
> 'with_empty' => false));
>
> $this->validatorSchema['DataInizioValidita'] = new
> sfValidatorDateRange(array('from_date' => new ssValidatorDate(array
> ('date_format' => '/^\d\d?-\d\d?-\d\d\d\d$/',
>
> 'required' => false),
>
> array('bad_format' => 'La data deve essere indicata come gg-mm-aaaa.',
>
> 'invalid' => 'Data errata.')),
>
> 'to_date' => new ssValidatorDate(array('date_format' => '/^\d\d?-\d
> \d?-\d\d\d\d$/',
>
> 'required' => false),
>
> array('bad_format' => 'La data deve essere indicata come gg-mm-aaaa.',
>
> 'invalid' => 'Data errata.'))),
>
> array('invalid' => 'La data iniziale deve essere antecedente alla data
> finale.'));
>
> }
>
> }
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---