Wednesday 13 January 2010

sfValidatorI18nChoiceLanguage does not support the following options: 'culture'.

This is the first of two posts about the sfFormExtra plugin after finding a bug and an interesting 'inconsistency' yesterday.

We had need to use the language form bundled with the FormExtra plugin yesterday to build a microsite that needs to handle 4 languages. However, trying to implement the form resulted in the following error:

sfValidatorI18nChoiceLanguage does not support the following options: 'culture'.


The bug is logged in the Symfony ticket system but is not fixed yet. There is a patch at the link over there, but to be honest, it's just as easy to manually correct it until a new release fixes it.

Basically, change a line in the sfFormLanguage::configure() method from:
$this->setValidators(array(
       'language' => new sfValidatorI18nChoiceLanguage(array('culture' => $this->user->getCulture(), 'languages' => $this->options['languages'])),
));
to
$this->setValidators(array(
       'language' => new sfValidatorI18nChoiceLanguage(array('languages' => $this->options['languages'])),
));

Problem solved :)

6 comments:

Please leave your feedback and comments. I love to discuss this stuff!