-
-
Notifications
You must be signed in to change notification settings - Fork 174
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
DatetimePicker no inital value and other position #96
Comments
<?= $form->field($model, 'from_date')->widget(DateControl::classname(),[
'type' => DateControl::FORMAT_DATE,
]); ?>
<?= $form->field($model, 'datetime_1')->widget(DateControl::classname(), [
'type'=>DateControl::FORMAT_DATETIME,
'options' => [
'pluginOptions' => [
'pickerPosition' => 'bottom-right'
]
]
]); ?> |
@kartik-v Hello Kartik As you can see in the following picture in method My next question was: "why does DatetimePicker fail while DatePicker works?" |
@erik-r With regards to the datetimepicker plugin... its better if a PR is raised on this with the author. I have currently updated the locale Will check on the other details that you have mentioned. |
@erik-r the If |
@kartik-v Concerning formatting I'm not your opinion with following arguments:
Without a change on your side a developer must inherit your class and override 'init' method if he wants to have dynamically programed localized application. Thank you for your good work again. |
@erik-r - DateControl already formats and converts date to javascript format... for known widget types - But it cannot do it for other arbitrary third party widgets or plugins - because it depends on the way plugin is coded and the plugin may have its own property naming and options to control formats. Hence, in such cases (when Are you facing a challenge setting your own custom defaults for the widget from the module? The displayFormat you need can be setup within the module configuration which can be picked up by DatePicker. |
@kartik-v Yes I know that DateControl can't set pluginOptions for other plugins. In this case I agree with you completely. But for your own DatePicker and Datetimepicker also you can. I'm thinking about working with I will try the same with your activeForm settings. |
@erik-r you probably can achieve this easier than that. You can use Yii's feature to set global class defaults this way. For example, you can call this in your config or index file: \Yii::$container->set('kartik\widgets\DatePicker', [
'pluginOptions' => [
'format' => 'dd.mm.yyyy',
],
]); I am not aware of your configuration. But I think you SHOULD BE ABLE TO setup the DateControl module defaults this way (and setup your widget format defaults for your language): use kartik\datecontrol\Module;
...
'modules' => [
'datecontrol' => [
'class' => 'kartik\datecontrol\Module',
// format settings for displaying each date attribute
'displaySettings' => [
Module::FORMAT_DATE => 'd.m.Y',
Module::FORMAT_TIME => 'H:i:s',
Module::FORMAT_DATETIME => 'd.m.Y H:i:s',
],
// format settings for saving each date attribute
'saveSettings' => [
Module::FORMAT_DATE => 'Y-m-d',
Module::FORMAT_TIME => 'H:i:s',
Module::FORMAT_DATETIME => 'Y-m-d H:i:s'
],
// disable automatic use of kartik\widgets for each of the above formats
'autoWidget' => false,
// setup your date picker widget default options
'widgetSettings' => [
Module::FORMAT_DATE => [
'class' => 'kartik\widgets\DatePicker',
'options' => [
'convertFormat'=>true,
'pluginOptions'=>['format'=>'dd.mm.yyyy'],
]
],
],
// other settings
], |
Thank your for info. It's work perfectly. |
@kartik-v Sorry about my comming again. I was too early with positiv feedback. Container setting works if nothing overrides later. (eg. ActiveForm config). But
\Yii::$container->set('kartik\widgets\DatePicker', [
'type' => 2,
'pluginOptions' => [
'autoclose' => true,
'keyboardNavigation' => false,
],
]);
DateControl overrides I tried to set So I tried setting default values with <?= $form->field($model, 'rcv_out_date')->widget(DateControl::className(), [
'type'=>DateControl::FORMAT_DATE , 'options' => Yii::$app->params['kv-DatePicker'] Now, it works. pluginOptions has a merge now with format from DateControl and others from params. It's a little bit complicate for developers without a wiki. |
@erik-r I mentioned But for the datecontrol module - its simpler, because you can override and setup your settings at the module level as I had mentioned (if you are setting this module, you do not need Again its relatively simple -- here are the steps to follow for your global defaulting sequence:
You just need to set this up in your module for DatePicker to work - not sure why its complicated (check and let know if the following sample works for you - or what's the error you are facing): use kartik\datecontrol\Module;
...
'modules' => [
'datecontrol' => [
'class' => 'kartik\datecontrol\Module',
// disable automatic use of kartik\widgets for each of the above formats
'autoWidget' => false,
// setup your date picker widget default options
'widgetSettings' => [
Module::FORMAT_DATE => [
'class' => 'kartik\widgets\DatePicker',
'options' => [
'type'=>2,
'convertFormat'=>true,
'pluginOptions'=>[
'format'=>'dd.mm.yyyy',
'autoclose' => true,
'keyboardNavigation' => false,
],
]
],
],
// other settings
], |
@kartik-v This I know, but now I see what you don't see. I DON'T want to hard code |
@erik-r - I will enhance the autoWidget options with an additional |
The module has been upgraded to version 1.1.0. Refer change log and documentation - especially the defaulting rules section.
|
I have one page in which I use DatePicker (via DateControl) and DatetimePicker (also via DateControl)
DatetimePicker starts with a date in year 1899 always while Datepicker takes the given value from input. see Screenshots:
Further Datepicker checks which is best position top or bottom and it starts left of input field. Datetimepicker goes out of screen without pluginOptions. In screenshot I set
'pluginOptions' => ['pickerPosition' => 'top-left']
. As you can see it's better but it's not at the same place as Datepicker. It's not relevant for functionality but it's not good for application's common behavior.The text was updated successfully, but these errors were encountered: