Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Language defining in pluginOptions is ignoring #10

Closed
antonkomarev opened this issue Jan 5, 2015 · 4 comments
Closed

Language defining in pluginOptions is ignoring #10

antonkomarev opened this issue Jan 5, 2015 · 4 comments
Labels

Comments

@antonkomarev
Copy link

I'm using 1.2.0 widget with Russian language defined in application config:

'language' => 'ru-RU',

In this case all datepickers will use Russian language.

But if you want to use english language for specific widget - pluginOptions language property will be ignored:

$form->field($model, 'birthDate')->widget(
    DatePicker::classname(),
    [
        'convertFormat' => true,
        'pluginOptions' => [
            'language' => 'en',
            'endDate' => '31-12-1999',
            'format' => 'dd-MM-yyyy',
            'autoclose' => true,
            'startView' => 'decade',
        ]
    ]
);

'language' => 'en-GB' isn't working too. And even if no language setted in application config pluginOptions language will be ignored.

// Assets were cleaned up on each test.

@kartik-v
Copy link
Owner

kartik-v commented Jan 5, 2015

While this fix is not related.. your issue is different:

You MUST not set pluginOptions['language'] directly.. you must set the language property directly in the widget instead and it will get calculated and generated for plugin options

echo DatePicker::widget([
    'language' => 'en',
    'pluginOptions' => [
        'format'=>'dd-mm-yy'
    ]
])

@antonkomarev
Copy link
Author

Thanks. It just was worked in pluginOptions before, so I've noticed changes and reported them.
I'm looking in widget's code and can't find where is function initLanguage() is called :{

@kartik-v
Copy link
Owner

kartik-v commented Jan 5, 2015

Please read my last comment again. The fix for initLanguage is not related to this widget or issue.

For your language related fix - DO NOT pass pluginOptions['language'], instead pass the language property in the widget settings directly (it will get copied to pluginOptions).

echo DatePicker::widget([
    'language' => 'en',
    'pluginOptions' => [
        'format'=>'dd-mm-yy'
    ]
])

@antonkomarev
Copy link
Author

Yes, I understood that and checked code already, it's working when language passing not as pluginOptions['language'].
Asked about function initLanguage() just to clarify how it all works. I thought I missed something.
Thanks for explanations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants