Code Monkey home page Code Monkey logo

Comments (4)

re8us avatar re8us commented on August 26, 2024 1

It seems may be like this

<?= $form->field($model, 'done_till')->widget(DatePicker::className(), 
    [
        'inline' => true,
        'template' => '<div class="well" style="background-color: #fff; width:250px">{input}</div>', 
        'language' => 'ru',
        'clientOptions' => [ 
            'autoclose' => true, 
            'format' => new JsExpression('{
                toDisplay: function (date, format, language) {
                    var d = new Date(date);
                    d.setDate(d.getDate() - 7);
                    return d.toISOString();
                },
                toValue: function (date, format, language) {
                    var d = new Date(date);
                    d.setDate(d.getDate() + 7);
                    return new Date(d);
                }
            }'),
        ]
    ]
);?>

or like this

<?= $form->field($model, 'done_till')->widget(DatePicker::className(), 
    [
        'inline' => true,
        'template' => '<div class="well" style="background-color: #fff; width:250px">{input}</div>', 
        'language' => 'ru',
        'clientOptions' => [ 
            'autoclose' => true, 
            'format' => [
                'toDisplay' => new JsExpression('function (date, format, language) {
                    var d = new Date(date);
                    d.setDate(d.getDate() - 7);
                    return d.toISOString();
                }'),
                'toValue' => new JsExpression('function (date, format, language) {
                    var d = new Date(date);
                    d.setDate(d.getDate() + 7);
                    return new Date(d);
                }')
            ]
        ]
    ]
);?>

But it doesn't work.
Any ideas?

from yii2-date-picker-widget.

re8us avatar re8us commented on August 26, 2024 1

@tonydspaniard sure

jQuery(document).ready(function () {
;jQuery('#task-deadline').parent().datepicker({"autoclose":true,"format":"dd.mm.yyyy","class":"col-md-3","language":"ru"});
;jQuery('#task-done_till').parent().datepicker({"autoclose":true,"format":{
                toDisplay: function (date, format, language) {
                    var d = new Date(date);
                    d.setDate(d.getDate() - 7);
                    return d.toISOString();
                },
                toValue: function (date, format, language) {
                    var d = new Date(date);
                    d.setDate(d.getDate() + 7);
                    return new Date(d);
                }
            },"language":"ru"});
;jQuery('#task-done_till').parent().on('changeDate', function (e){ jQuery('#task-done_till').val(e.format());});
jQuery('#w0').yiiActiveForm([{"id":"task-sum","name":"sum","container":".field-task-sum","input":"#task-sum","error":".help-block.help-block-error","validate":function (attribute, value, messages, deferred, $form) {yii.validation.number(value, messages, {"pattern":/^\s*[+-]?\d+\s*$/,"message":"Значение «Сумма» должно быть целым числом.","skipOnEmpty":1});}}], []);
});

and error
2016-09-10 20 46 02

from yii2-date-picker-widget.

tonydspaniard avatar tonydspaniard commented on August 26, 2024

@re8us what is the response on your browser? can we have a look at the javascript code rendered?

from yii2-date-picker-widget.

tonydspaniard avatar tonydspaniard commented on August 26, 2024

Thanks! checking

from yii2-date-picker-widget.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.