Code Monkey home page Code Monkey logo

Comments (8)

mahesheu avatar mahesheu commented on July 23, 2024 2

i had the same issue but when i gave it like this

<?= $form->field($model, 'dob')->widget(
                    DatePicker::className(),
                    [
                        'clientOptions' => [
                            'autoclose' => true,
                            'format' => 'yyyy-mm-dd'
                        ]
                    ]
                ); ?>

instead of

 <?= DatePicker::widget([
                'model' => $model,
                 'attribute' => 'dob',
                'template' => '{addon}{input}',
                'clientOptions' => [
                'autoclose' => true,
                'format' => 'yyyy-mm-dd'
                ]
            ]);?>

it started to work.

from yii2-date-picker-widget.

tonydspaniard avatar tonydspaniard commented on July 23, 2024

Could be that you hace changed its template

from yii2-date-picker-widget.

codepolariz avatar codepolariz commented on July 23, 2024

No, i didn't modify the template in any way this is my view code

<?= DatePicker::widget([
'model' => $model,
'attribute' => 'dob',
'template' => '{addon}{input}',
'clientOptions' => [
'format' => 'L',
'autoclose' => true,
'format' => 'yyyy-mm-dd', 
'endDate'=> '1970-12-31', 
]
]);?>

from yii2-date-picker-widget.

tonydspaniard avatar tonydspaniard commented on July 23, 2024
'template' => '{addon}{input}',

What if we use:

<?= $form->field($model, 'dob')->widget(
                    DatePicker::className(),
                    [
                        'clientOptions' => [
                            'autoclose' => true,
                            'format' => 'yyyy-mm-dd'
                        ]
                    ]
                ); ?>

from yii2-date-picker-widget.

philippfrenzel avatar philippfrenzel commented on July 23, 2024

Hey, have the same issue - any updates on this one?

from yii2-date-picker-widget.

tonydspaniard avatar tonydspaniard commented on July 23, 2024

@philippfrenze I need more info as I do use the widget and certainly the validation happens.

from yii2-date-picker-widget.

faniuta avatar faniuta commented on July 23, 2024

use regx and preg_match($format, $date) after get time and check valid time ,u can define validator in model

from yii2-date-picker-widget.

tonydspaniard avatar tonydspaniard commented on July 23, 2024

@mahesheu already gave the solution and is as I suspected on the client side for the template.

The problem on the server could be that somehow the dob is filled with values and thats why is not firing when validating. The solution provided by @faniuta could be the best and also including trim filter on our rules too.

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.