This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use the new forum.
Home » plugins » General plug-ins » how do I change sfWidgetFormJQueryDate culture ?
how do I change sfWidgetFormJQueryDate culture ? [message #79773] Fri, 12 June 2009 15:24 Go to next message
JessOVR  is currently offline JessOVR
Messages: 48
Registered: April 2008
Location: France
Member
Hi,

I'm using symfony 1.2.7 + sfJqueryReloadedPlugin + sfFormExtraPlugin, then I've manually installed Jquery UI (jquery-ui-1.7.2.custom.min.js, in view.yml) because could not find any plugin doing it for me), so that I get the nice jQuery date widget working with sfFormExtraPlugin...

so, it's working but :
I'm trying to set the widget culture accordingly to that of current User, like this :

    $this->widgetSchema['birthday'] = new sfWidgetFormJQueryDate(
      array(
        'config'  => "{}",
        'image'   => "/images/date.png",
        'culture' => sfContext::getInstance()->getUser()->getCulture(),
        )
        );


It still displays the widget with default english culture.
I guess there are some additionnal files to load that contain other cultures. But what/where are these files ? How/where do I load them ?

thank you Smile
Re: how do I change sfWidgetFormJQueryDate culture ? [message #79789 is a reply to message #79773 ] Fri, 12 June 2009 21:39 Go to previous messageGo to next message
xplo  is currently offline xplo
Messages: 428
Registered: September 2008
Faithful Member
you need to load the translation .js from the subdirectory i18n in jquery ui lib folder
Re: how do I change sfWidgetFormJQueryDate culture ? [message #79795 is a reply to message #79789 ] Fri, 12 June 2009 22:27 Go to previous messageGo to next message
JessOVR  is currently offline JessOVR
Messages: 48
Registered: April 2008
Location: France
Member
thank you for helping Smile

ok, I've added jquery-ui-i18n.js (which contains translation for all cultures) in the application view.yml.

problem is that this file set the default regional settings in it (hardcoded), after each culture block.
Then whatever regional you set in sfWidgetFormJQueryDate 'culture' parameter, it is overridden by the loading of that file (which set the datepicker regional setting).

I see only one solution :
having all separate culture files, and then load the corresponding file dynamically (according to current user culture),
with $response->addStyleSheet method.

I would have prefer a more flexible sfWidgetFormJQueryDate API (quite limited. It's another problem but for example, how do I set the min and max date ?)

What do you think about it ?
Re: how do I change sfWidgetFormJQueryDate culture ? [message #79798 is a reply to message #79795 ] Fri, 12 June 2009 22:47 Go to previous messageGo to next message
xplo  is currently offline xplo
Messages: 428
Registered: September 2008
Faithful Member
well there is already 1 file per culture in the 18n folder.
I actually didnt use yet ui datapicker with dynamic culture so i didnt see the jquery-ui-i18n.js file ^^;
I tried to load this file instead of my localised js file and my datepickers were still in my local language.
And as i see the js file it shouldnt override the culture
if u got the same as mine it should start like this :

jQuery(function($){
	$.datepicker.regional['ar'] = {


It looks ok in my project so maybe u got a bad version of jqeury ui.

For the date range sfWidgetFormJQueryDate extend sfWidgetFormDate so it s possible to change the year range like that (but i think a startdate and enddate would be better)
$years = range(1920,date('Y'));
$this->setWidget('collabo_date_naissance',new sfWidgetFormJQueryDate(array('years' => array_combine($years, $years), 'format' => '%day%%month%%year%','config' => '{firstDay: 1, changeMonth: true, changeYear: true}','culture' => 'fr')));
Re: how do I change sfWidgetFormJQueryDate culture ? [message #79799 is a reply to message #79798 ] Fri, 12 June 2009 23:23 Go to previous messageGo to next message
JessOVR  is currently offline JessOVR
Messages: 48
Registered: April 2008
Location: France
Member
xplo wrote on Fri, 12 June 2009 22:47

It looks ok in my project so maybe u got a bad version of jqeury ui.

ok, problem solved : my mistake was that I've had only put query-ui-1.7.2.custom.min.js file on the server, and not all files coming beside (like core.js etc.) Laughing Embarassed
Quote:

For the date range sfWidgetFormJQueryDate extend sfWidgetFormDate

!!! that's it, I did not realize this class inherits from it so it can use parent options, great !
Quote:

so it s possible to change the year range like that (but i think a startdate and enddate would be better)
$years = range(1920,date('Y'));
$this->setWidget('collabo_date_naissance',new sfWidgetFormJQueryDate(array('years' => array_combine($years, $years), 'format' => '%day%%month%%year%','config' => '{firstDay: 1, changeMonth: true, changeYear: true}','culture' => 'fr')));


by the way, should the 'format' not be also culture-dependent ?
I mean, now, the datepicker display a nice grid corresponding to the user culture, but still have the 3 drop down in english (default) month-day-year order (unless I set a specific 'format' param like yours above).
The format is not following the culture parameter.
Re: how do I change sfWidgetFormJQueryDate culture ? [message #79802 is a reply to message #79799 ] Sat, 13 June 2009 00:16 Go to previous messageGo to next message
xplo  is currently offline xplo
Messages: 428
Registered: September 2008
Faithful Member
i guess it would make sense, you could ask the sfFormExtraPlugin dev team for it maybe ~
Re: how do I change sfWidgetFormJQueryDate culture ? [message #92558 is a reply to message #79773 ] Sat, 30 January 2010 07:48 Go to previous messageGo to next message
apm12  is currently offline apm12
Messages: 7
Registered: January 2010
Junior Member
sfWidgetFormJQueryDate does not support the following options: 'years'.
Re: how do I change sfWidgetFormJQueryDate culture ? [message #102813 is a reply to message #79773 ] Tue, 20 July 2010 17:11 Go to previous message
sinned  is currently offline sinned
Messages: 3
Registered: February 2008
Junior Member
the options from the default datepicker are still available, but you have to use a sfWidgetFormDate object in your options:

        $years = range(date('Y') - 10, date('Y'));

        $this->setWidgets(array(
            'your_date'    => new sfWidgetFormJQueryDate(array(
                'date_widget' => new sfWidgetFormDate(array(
                    'years'       => array_combine($years, $years)
                 ))
            ))
        ));


See also http://trac.symfony-project.org/ticket/8041
Previous Topic:Save multiple values with autocompleter widget from sfFormExtraPlugin
Next Topic:sfDoctrineRestGeneratorPlugin 0.9.2 - How to use logical clauses
Goto Forum:
  

powered by FUDforum - copyright ©2001-2004 FUD Forum Bulletin Board Software