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">×</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.