what is the best way to render CJuiDatePicker as form element using CForm builder with array of elements?

StackOverflow https://stackoverflow.com/questions/6305294

  •  26-10-2019
  •  | 
  •  

문제

I have a CForm builder code in my action:

    $form = new CForm(
        'application.components.portlets.views._newClientForm', 
        $model
    );

and array of input elements:

<?php
return array(
    'elements'=>array(
        'client_type'=>array(
            'type'=>'radiolist',
            'items'=>Client::getClientTypes()
        ),
        'mainPersonName1'=>array(
            'type'=>'text',
        ),

How can i render a CJuiDatePicker in my form ?

도움이 되었습니까?

해결책

In your view file:

<?php
    $this->widget('zii.widgets.jui.CJuiDatePicker',array(
                                                   'name'=>'arbitraryName',
                                                   'model'=>$model,
                                                   'attribute'=>'nameOfFormAttribute',
                                                   'options'=>array(
                                                              'jqueryOption'=>'jqueryOptionValue',
                                                              ),
                                                   ),
    );
 ?>

Obviously, you have to pass your $model object into the view for this to work.

::UPDATE:: Using only Cform you would do it this way: http://www.yiiframework.com/forum/index.php?/topic/7016-using-zii-cjuidatepicker-in-a-cform/

다른 팁

'dob'=>array(
                       'type'=>'zii.widgets.jui.CJuiDatePicker',
                       'options'=>array(

                          'showAnim'=>'fold',
                          'dateFormat'=>'yy-mm-dd',
                      ),
            ),
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top