Yii framework datepicker

Hi all,

I am new to Yii framework I need some help!

Installed Version: Yii2

yiisoft\jui\DatePicker;

I was developing a form with datepicker, and I installed the yii\jui\DatePicker

All good the installation.

But I want when someone open the form to see the dafult date and the if he want to change it to select the calentar.

I search the code but I could not figure out any solution.

I search about to use ‘options’ => [‘placeholder’ => ‘22/2/2018’] but I could not make it work.

Is it something in the widget a flag or something that make the text from blank to giving the today date before the selection?

Please, any one help me!

Hi nefeli, welcome to the forum.

Just set the default date in the model.




    public function actionCreate()

    {

        $model = new Bp();

        $model->date = date('Y-m-d');


        if ($model->load(Yii::$app->request->post())) {

            if (Yii::$app->request->isAjax) {

                Yii::$app->response->format = Response::FORMAT_JSON;

                return ActiveForm::validate($model);

            }

            if ($model->save()) {

                return $this->redirect(['index']);

            }

        }

        return $this->render('create', [

            'model' => $model,

        ]);

    }



Hi,

thank you so much for the solution.

Thank you for the help.

Happy to be member of the forum