2

I am trying to use yii\jui\DatePicker but for some reason DatePicker is not rendering the jquery ui widget. As a result clicking the input field does not open calendar. Firebug is not showing anything.. any thought about the cause of this?

Here is my code:

<?php use yii\jui\DatePicker; ?>

<?=
  DatePicker::widget([
    'model' => $model,
    'attribute' => 'entryDate',
    'language' => Yii::$app->language,
    'dateFormat' => 'yyyy-MM-dd',
  ]);
?>

I have tried to implement the above in a new yii2 basic template and it works fine. I wonder what could be the problem in my existing project.

Other components in my view are yii\helpers\Html yii\widgets\ActiveForm. Below is my view:

<?php
  use yii\helpers\Html;
  use yii\widgets\ActiveForm;
  use yii\jui\DatePicker;

  $this->title = Html::encode($this->context->getShopNameByUserId(Yii::$app->user->id));
?>
<div class="content">
  <div class="main-content">
    <div class="widget widget-table">
      <div class="widget-header" style="padding-right:0px;">
        <h3><i class="fa fa-credit-card"></i> <?= Yii::t('user', 'Add/Edit Coupon') ?></h3>
      </div>
      <div class="widget-content">
        <?php $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]) ?>
        <?=
          DatePicker::widget([
            'model' => $model,
            'attribute' => 'entryDate',
            'language' => Yii::$app->language,
            'dateFormat' => 'yyyy-MM-dd',
          ]);
        ?>
        <?= Html::submitButton(Yii::t('user', 'Save'), ['class' => 'btn btn-custom-primary']) ?>
        <?php ActiveForm::end(); ?>
    </div>
  </div>
</div>

2
  • 1
    can you add the code you are using to render the widget? Commented Sep 1, 2015 at 16:00
  • @marche thanks for your time, I just edited my question for more clarifications Commented Sep 2, 2015 at 12:43

1 Answer 1

1

When I've used the Yii2 DatePicker widget previously it's always been in the ActiveField ->widget() method:

<?php

echo $form->field($Model, 'entryDate')->widget(DatePicker::classname(), [ 'dateFormat' => 'php:d/m/Y', 'options'=> ['class'=>'form-control']])->hint('When does this take place?');

?>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.