GoldenTabby
GoldenTabby

Reputation: 220

sfWidgetFormJQueryDate doesn't pass validation in Symfony 1.4

I'm trying to add sfWidgetFormJQueryDate to my project, but it doesn't want to pass validation, it shows "Date Invalid" when I'm trying to filter.
Here's the code:

 $this->setWidgets(array(
        'date' => new sfWidgetFormDateRange(
            array(
                'from_date' => new sfWidgetFormJQueryDate(array(
                        'config' => '{buttonText: "Choose Date"}',
                        'date_widget' => new sfWidgetFormDate(array('format' => '%year%-%month%-%day%'))
                    )
                ),
                'to_date' => new sfWidgetFormJQueryDate(array(
                        'config' => '{buttonText: "Choose Date"}',
                        'date_widget' => new sfWidgetFormDate(array('format' => '%year%-%month%-%day%'))
                    )
                ))),
    // ...
    $this->setValidators(array(
        'date' => new sfValidatorDateRange(
            array('required' => false,
                'from_date' => new sfValidatorDate(
                    array('required' => false)
                ),
                'to_date' => new sfValidatorDate(
                    array('required' => false)
                ))),

I am probably missing something.

Upvotes: 1

Views: 609

Answers (1)

GoldenTabby
GoldenTabby

Reputation: 220

I found the answer, it's a bug in javascript of sfWidgetFormJQueryDate.

sfWidgetFormJQueryDate.class.php, line 106. Need to change

jQuery("#%s option").attr("disabled", '');

to

jQuery("#%s option").attr("disabled", false);

Because wrong code causes all options of day be disabled.

Upvotes: 7

Related Questions