kartik-v / yii2-date-range

A Date Range Picker for Bootstrap useful for reports and filtering.
http://demos.krajee.com/date-range
Other
93 stars 81 forks source link

Language problems on extending widget #165

Closed empytree closed 2 years ago

empytree commented 2 years ago

When you use class extended from the widget and therefore located elsewhere, language asset for Moment fails to register: https://github.com/kartik-v/yii2-date-range/blob/master/src/DateRangePicker.php#L303 (empty $this->_langFile)

I believe the problem is linked with that line: https://github.com/kartik-v/yii2-date-range/blob/master/src/DateRangePicker.php#L388

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

kartik-v commented 2 years ago

This is fixed via kartik-v/yii2-krajee-base#119

New property sourcePath available in DateRangePicker and other Krajee widgets which you can override like below.

// your custom extended widget
namespace myapp\widgets;
class MyDateRangePicker extends kartik\daterange\DateRangePicker {
    // directly set the property to the original Krajee base widget directory
    // you can use Yii path aliases
    public $sourcePath = '@vendor/kartik-v/yii2-date-range/src';
}

// Alternatively you can also override this property while rendering the widget
// view.php: where widget is rendered
use myapp\widgets\MyDateRangePicker;

echo MyDateRangePicker::widget([
    'name' => 'custom',
    'sourcePath' => '@vendor/kartik-v/yii2-date-range/src'
]);