Question

Yii bootstrap widgets TbDatePicker not hiding after select a date.

<?php
 echo $form->labelEx($modelRenterStatus,'moving_date');
 $this->widget('bootstrap.widgets.TbDatePicker', array(
        'model' => $modelRenterStatus,
        'attribute' => 'moving_date',
        'options' => array(
            'size' => '10',         // textField size
            'maxlength' => '10',    // textField maxlength
            'autoclose' => true,
        ),
    ));
?>

what's wrong with my this code?

Was it helpful?

Solution

According to YB Docs Options are

options for the original library. This value will be JSON-encoded and fed to bootstrap-datepicker

And looking into library docs here I can't see the options you have put and so they are invalid.

Taking example from YB site

$this->widget(
    'bootstrap.widgets.TbDatePicker',
    array(
    'name' => 'some_date_jap',
    'options' => array(
    'language' => 'ja'
    ))
 );

language is option in original library. So recheck it again!

Just to expand my answer here is one that works with my form

<?php 
echo $form->datepickerRow($model, 'mode_attribute_here',array('hint'=>'',
                                            'prepend'=>'<i class="icon-calendar"></i>',
                                            'options'=>array('format' => 'yyyy-mm-dd' , 'weekStart'=> 1)
)); ?>

OTHER TIPS

maybe it help others!! More detail here

<?php
 echo $form->labelEx($modelRenterStatus,'moving_date');
  $this->widget('bootstrap.widgets.TbDatePicker', array(
    'model' => $modelRenterStatus,
    'attribute' => 'moving_date',
    'options' => array(
        'size' => '10',         // textField size
        'maxlength' => '10',    // textField maxlength
        'autoclose' => true,
    ),
  ));
?>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top