| i18n form question [message #68688] |
Sun, 28 December 2008 16:33  |
Mindphreaker Messages: 151 Registered: December 2008 Location: Austria |
Senior Member |
|
|
Hello!
I'm trying to put some I18n elements into my form. I tried the sfWidgetFormI18nDate element:
$this->widgetSchema['birthday'] = new sfWidgetFormI18nDate(array(
'culture' => 'en',
));
The date format should switch automatically when the user culture gets switched. Am I supposed to add more cultures in the widget options?
Another little question:
The date widget only shows me 2003 to 2013. Is this also an option or where can I configure this?
Regards,
Alex
See my favourite websites!
Complexity is relative. Relativity is complex. - Anonymous
Anyone who can give you orders can stop you from solving whatever problem you're being fascinated by. - Eric. S. Raymond
|
|
|
| Re: i18n form question [message #68703 is a reply to message #68688 ] |
Sun, 28 December 2008 19:51   |
Mindphreaker Messages: 151 Registered: December 2008 Location: Austria |
Senior Member |
|
|
At least I found a solution to pass the user culture to the form:
$this->form = new myForm(null, array('culture' => $this->getUser()->getCulture()));
public function getCurrentCulture()
{
return isset($this->options['culture']) ? $this->options['culture'] : 'en';
}
The second thing is still unsolved, does someone know how to configure the date range shown up in the year field? For a birthday field it should show up at least 100 years backwards from the current year.
See my favourite websites!
Complexity is relative. Relativity is complex. - Anonymous
Anyone who can give you orders can stop you from solving whatever problem you're being fascinated by. - Eric. S. Raymond
|
|
|
|
| Re: i18n form question [message #69349 is a reply to message #69347 ] |
Wed, 07 January 2009 11:10   |
Mindphreaker Messages: 151 Registered: December 2008 Location: Austria |
Senior Member |
|
|
Thanks a lot!
I was searching around in the documentations but could not find such a parameter.
Maybe this code snippet should be implemented in the documentation.
See my favourite websites!
Complexity is relative. Relativity is complex. - Anonymous
Anyone who can give you orders can stop you from solving whatever problem you're being fascinated by. - Eric. S. Raymond
|
|
|
| Re: i18n form question [message #69632 is a reply to message #68703 ] |
Sun, 11 January 2009 05:34  |
inde Messages: 14 Registered: December 2008 |
Junior Member |
|
|
| Mindphreaker wrote on Sun, 28 December 2008 19:51 | At least I found a solution to pass the user culture to the form:
$this->form = new myForm(null, array('culture' => $this->getUser()->getCulture()));
public function getCurrentCulture()
{
return isset($this->options['culture']) ? $this->options['culture'] : 'en';
}
|
This can also be done using the sfContext:
$this->widgetSchema['birthday'] = new sfWidgetFormI18nDate(array(
'culture' => sfContext::getInstance()->getUser()->getCulture(),
));
[Updated on: Sun, 11 January 2009 05:35]
|
|
|