YiiBooster, TbDatePicker and TbModal

Hi,

I am running YiiBooster 4.01 which uses Bootstrap 3.1.1

I have a view file that is a form (_form). When I render this file directly from a controller action, the date is formatted as I wish (dd-mm-yyyy). when I click the field, the calendar popup appears with the correct date selected and when I select a different date, the input is updated to the new date in the correct format. I have this working in numerous pages in my site so im happy that the code is correct.

Now on a particular view file I load another view file that is a modal shell, and this file loads the above-mentioned form view file. When the modal form is open the datepicker field is displayed with the correct date listed in the correct format. All good so far.

When I click the field, the calendar opens but todays date is selected rather than the date listed in the input field. Further to this, if I select another date from the calendar, the date is updated to the selected date but the format is all wrong, it is listed as mm/dd/yyyy!

So the form view file is the same file in each scenario, the difference is in the first option is it called directly from the controller action with "render". In the second scenario is it called as follows:

controller action > render("show") > renderpartial("editevent") > renderpartial("_form")

Code from the modal shell view file ("editevent"):




<?php

$this->beginWidget('booster.widgets.TbModal',

array(

    'id' => "editeventdlg",

    'fade' => false,

)); 

?>


<div class="modal-header">

<a class="close" data-dismiss="modal">&times;</a>

<h4>Update Event</h4>

</div>


<div class="modal-body">

<?php

$this->renderPartial("_form", array("model"=>$model, 'formmode'=>'edit')); ?>

</div>



Code snippet from the form view file ("_form").




            <tr>

                <td>

		<?php echo $form->labelEx($model,'enddate'); ?>

                </td>

                <td>

		<?php 

                $this->widget('booster.widgets.TbDatePicker',

                    array(

                    'name' => "Calendar[$formmode][enddate]",

                    'value' => $model->enddate,

                    'htmlOptions' => array('style'=>'width:120px;min-width:120px'),

                    'options'=> 

                        array(

                            'weekStart' => 1,

                            'format'=> "dd-mm-yyyy",

                            'orientation'=> "bottom right",

                            'autoclose'=> true,

                        ),

                    )

                );                

                

                ?>

		<?php echo $form->error($model,'enddate'); ?>

                </td>

            </tr>



I have spent most of the day on this and for the life of me I cannot work it out! I have simplified the code as much as I can but still not getting anywhere!

Any help would be greatly appreciated.

regards

Greg J

ok, have resolved this issue. there are additional parameters for the renderPartial method that need to be set, namely the 4th parameter needs to be set to true. So how I have the correct behaviour in the modal dialog but other things are now broken due to this.

Now the js code that is loaded in the first view file cannot find a custom function in an attached js file.

one step forwards, 2 steps back…

Greg J

Greg, I would like to upgrade to YiiBooster 4, but I can’t tell if it is for Yii 1 or Yii 2. I’ve read over their site, downloaded, etc., and it appears to be for Yii 1.x. Which version of Yii are you using it with?

Thanks,

Dave

[color="#006400"]/* NOTE: moved from Tips, Snippets and Tutorial */[/color]

Dave,

I am using YiiBooster 4.01 with Yii 1.1.16

Cheers

Greg J

Great! Thanks very much, Greg!