src/widgets/ChartOptions.php
protected function initDefaults()
    {
        $id = $this->getId();

        $this->hiddenInputs = ArrayHelper::merge([
            'id' => ['value' => null, 'options' => []],
            'from' => ['value' => null, 'options' => []],
            'till' => ['value' => null, 'options' => []],
        ], $this->hiddenInputs);

        $this->form = ArrayHelper::merge([
            'action' => '#',
            'method' => 'post',
            'options' => [
                'class' => ['form-inline', $this->getId()],
            ],
        ], $this->form);

        $this->pickerOptions = ArrayHelper::merge([
            'class' => DateRangePicker::class,
            'name' => '',
            'options' => [
                'tag' => false,
                'id' => "{$id}-period-btn",
            ],
            'clientEvents' => [
                'apply.daterangepicker' => new JsExpression(/** @lang JavaScript */"
                    function (event, picker) {
                        var form = $(picker.element[0]).closest('form');
                        var span = form.find('#{$id}-period-btn span');

                        span.text(picker.startDate.format('ll') + ' - ' + picker.endDate.format('ll'));

                        form.find('input[name=from]').val(picker.startDate.format());
                        form.find('input[name=till]').val(picker.endDate.format());
                        form.trigger('change.updateChart');
                    }
                "),
                'cancel.daterangepicker' => new JsExpression(/** @lang JavaScript */"
                    function (event, picker) {
                        var form = $(event.element[0]).closest('form');
                        var span = form.find('#{$id}-period-btn span');

                        span.text(span.data('prompt'));

                        form.find('input[name=from]').val('');
                        form.find('input[name=till]').val('');
                        form.trigger('change.updateChart');
                    }
                "),
            ],
            'clientOptions' => [
                'ranges' => [
                    Yii::t('hipanel', 'Current Month') => new JsExpression('[moment().startOf("month"), new Date()]'),
                    Yii::t('hipanel', 'Previous Month') => new JsExpression('[moment().subtract(1, "month").startOf("month"), moment().subtract(1, "month").endOf("month")]'),
                    Yii::t('hipanel', 'Last 3 months') => new JsExpression('[moment().subtract(3, "month").startOf("month"), new Date()]'),
                    Yii::t('hipanel', 'Last year') => new JsExpression('[moment().subtract(1, "year").startOf("year"), new Date()]'),
                ],
            ],
        ], $this->pickerOptions);
    }
protected function initDefaults()
    {
        $id = $this->getId();

        $this->hiddenInputs = ArrayHelper::merge([
            'id' => ['value' => null, 'options' => []],
            'from' => ['value' => null, 'options' => []],
            'till' => ['value' => null, 'options' => []],
        ], $this->hiddenInputs);

        $this->form = ArrayHelper::merge([
            'action' => '#',
            'method' => 'post',
            'options' => [
                'class' => ['form-inline', $this->getId()],
            ],
        ], $this->form);

        $this->pickerOptions = ArrayHelper::merge([
            'class' => DateRangePicker::class,
            'name' => '',
            'options' => [
                'tag' => false,
                'id' => "{$id}-period-btn",
            ],
            'clientEvents' => [
                'apply.daterangepicker' => new JsExpression(/** @lang JavaScript */"
                    function (event, picker) {
                        var form = $(picker.element[0]).closest('form');
                        var span = form.find('#{$id}-period-btn span');

                        span.text(picker.startDate.format('ll') + ' - ' + picker.endDate.format('ll'));

                        form.find('input[name=from]').val(picker.startDate.format());
                        form.find('input[name=till]').val(picker.endDate.format());
                        form.trigger('change.updateChart');
                    }
                "),
                'cancel.daterangepicker' => new JsExpression(/** @lang JavaScript */"
                    function (event, picker) {
                        var form = $(event.element[0]).closest('form');
                        var span = form.find('#{$id}-period-btn span');

                        span.text(span.data('prompt'));

                        form.find('input[name=from]').val('');
                        form.find('input[name=till]').val('');
                        form.trigger('change.updateChart');
                    }
                "),
            ],
            'clientOptions' => [
                'ranges' => [
                    Yii::t('hipanel', 'Current Month') => new JsExpression('[moment().startOf("month"), new Date()]'),
                    Yii::t('hipanel', 'Previous Month') => new JsExpression('[moment().subtract(1, "month").startOf("month"), moment().subtract(1, "month").endOf("month")]'),
                    Yii::t('hipanel', 'Last 3 months') => new JsExpression('[moment().subtract(3, "month").startOf("month"), new Date()]'),
                    Yii::t('hipanel', 'Last year') => new JsExpression('[moment().subtract(1, "year").startOf("year"), new Date()]'),
                ],
            ],
        ], $this->pickerOptions);
    }
protected function initDefaults ( ) { $ id = $ this -> getId ( ) ; $ this -> hiddenInputs = ArrayHelper :: merge ( [ 'id' => [ 'value' => null , 'options' => [ ] ] , 'from' => [ 'value' => null , 'options' => [ ] ] , 'till' => [ 'value' => null , 'options' => [ ] ] , ] , $ this -> hiddenInputs ) ; $ this -> form = ArrayHelper :: merge ( [ 'action' => '#' , 'method' => 'post' , 'options' => [ 'class' => [ 'form-inline' , $ this -> getId ( ) ] , ] , ] , $ this -> form ) ; $ this -> pickerOptions = ArrayHelper :: merge ( [ 'class' => DateRangePicker :: class , 'name' => '' , 'options' => [ 'tag' => false , 'id' => "{$id}-period-btn" , ] , 'clientEvents' => [ 'apply.daterangepicker' => new JsExpression ( /** @lang JavaScript */ "
                    function (event, picker) {
                        var form = $(picker.element[0]).closest('form');
                        var span = form.find('#{$id}-period-btn span');

                        span.text(picker.startDate.format('ll') + ' - ' + picker.endDate.format('ll'));

                        form.find('input[name=from]').val(picker.startDate.format());
                        form.find('input[name=till]').val(picker.endDate.format());
                        form.trigger('change.updateChart');
                    }
                " ) , 'cancel.daterangepicker' => new JsExpression ( /** @lang JavaScript */ "
                    function (event, picker) {
                        var form = $(event.element[0]).closest('form');
                        var span = form.find('#{$id}-period-btn span');

                        span.text(span.data('prompt'));

                        form.find('input[name=from]').val('');
                        form.find('input[name=till]').val('');
                        form.trigger('change.updateChart');
                    }
                " ) , ] , 'clientOptions' => [ 'ranges' => [ Yii :: t ( 'hipanel' , 'Current Month' ) => new JsExpression ( '[moment().startOf("month"), new Date()]' ) , Yii :: t ( 'hipanel' , 'Previous Month' ) => new JsExpression ( '[moment().subtract(1, "month").startOf("month"), moment().subtract(1, "month").endOf("month")]' ) , Yii :: t ( 'hipanel' , 'Last 3 months' ) => new JsExpression ( '[moment().subtract(3, "month").startOf("month"), new Date()]' ) , Yii :: t ( 'hipanel' , 'Last year' ) => new JsExpression ( '[moment().subtract(1, "year").startOf("year"), new Date()]' ) , ] , ] , ] , $ this -> pickerOptions ) ; }
Initializes default values for the widget properties.
@void
Initializes default values for the widget properties .