Yii Framework Forum: Using Zii CJuiDatePicker in a CForm - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Using Zii CJuiDatePicker in a CForm Rate Topic: -----

#1 User is offline   toMeloos 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 49
  • Joined: 19-September 09

Posted 31 January 2010 - 10:28 AM

I'm trying to build my first form using the Yii 1.1 CForm form builder. I'd like to include a 'Date of birth' field, using a JQuery-based date picker. Found an example on this forum that uses the Zii date picker and took the liberty to copy it. Unfortunately this doesn't display a dateOfBirth field at all.

The 'elements' part of my form definition array includes:
		'dateOfBirth'=>array(
			'type'=>'zii.widgets.jui.CJuiDatePicker',
		),


So how should I implement it to get this to work?
0

#2 User is offline   amc 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 46
  • Joined: 13-March 09

Posted 31 January 2010 - 01:15 PM

.
0

#3 User is offline   swafsarl 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 17
  • Joined: 20-February 10

Posted 25 February 2010 - 08:58 AM

$form = new CForm(
        array(
        'showErrorSummary'=>true,
        'elements'=>array(
        'name'=>array('type'=>'text','maxlength'=>50,),
        'last_name'=>array('type'=>'text','maxlength'=>50,),

        '<div class="row field_birth_date">BirthDate</label>'.
        $this->renderPartial('_genericWidget',array('widName'=>'zii.widgets.jui.CJuiDatePicker','widData'=>array(
        'name'=>'birth_date','model'=>$this->signUpForm,
        'options'=>array('showAnim'=>'fold',),
        'htmlOptions'=>array('class'=>'formInput'),
        )),true).'</div>',

        'email'=>array('type'=>'text','maxlength'=>50,),
        'id_parrain'=>array('type'=>'text','maxlength'=>50,),
        'default_currency'=>array('type'=>'dropdownlist','items'=>Currency::model()->list,),
        'default_language'=>array('type'=>'dropdownlist','items'=>Language::model()->list,),
        'fax'=>array('type'=>'text','maxlength'=>10,),
        ),
        'buttons'=>array('signUp'=>array('type'=>'button','label'=>'Sign up',
'attributes'=>array('onclick'=>$this->renderSignUpAction())))
        ),$this->signUpForm);




The _genericWidget files contains the following code
<?PHP $this->widget($widName, $widData);?>

0

#4 User is offline   MaxLord 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 9
  • Joined: 31-March 12

Posted 03 May 2012 - 11:09 AM

View Postswafsarl, on 25 February 2010 - 08:58 AM, said:

$form = new CForm(
        array(
        'showErrorSummary'=>true,
        'elements'=>array(
        'name'=>array('type'=>'text','maxlength'=>50,),
        'last_name'=>array('type'=>'text','maxlength'=>50,),

        '<div class="row field_birth_date">BirthDate</label>'.
        $this->renderPartial('_genericWidget',array('widName'=>'zii.widgets.jui.CJuiDatePicker','widData'=>array(
        'name'=>'birth_date','model'=>$this->signUpForm,
        'options'=>array('showAnim'=>'fold',),
        'htmlOptions'=>array('class'=>'formInput'),
        )),true).'</div>',

        'email'=>array('type'=>'text','maxlength'=>50,),
        'id_parrain'=>array('type'=>'text','maxlength'=>50,),
        'default_currency'=>array('type'=>'dropdownlist','items'=>Currency::model()->list,),
        'default_language'=>array('type'=>'dropdownlist','items'=>Language::model()->list,),
        'fax'=>array('type'=>'text','maxlength'=>10,),
        ),
        'buttons'=>array('signUp'=>array('type'=>'button','label'=>'Sign up',
'attributes'=>array('onclick'=>$this->renderSignUpAction())))
        ),$this->signUpForm);




The _genericWidget files contains the following code
<?PHP $this->widget($widName, $widData);?>



don't work in a CForm.

CForm and its behaviors do not have a method or closure named "renderPartial"


screenshots:

gyazo.com/f6c923926bfd40bf148346a4a32e183f.png


gyazo.com/0a1adf7510ad1d6b2f707a81b33e4e2b.png
0

#5 User is offline   beebe 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 8
  • Joined: 03-May 12

Posted 03 May 2012 - 12:29 PM

One way to do it:
<?php
$form = $this->beginWidget('CActiveForm', array(
    'enableAjaxValidation'=>true,
    'enableClientValidation'=>true,
)); ?>
<?php
            $this->widget('zii.widgets.jui.CJuiDatePicker', array(
                'model'=>$model,
                'attribute'=>'dob',
                // additional javascript options for the date picker plugin
                'options'=>array(
                    'showAnim'=>'fold',
                    'showButtonPanel'=>true,
                    'autoSize'=>false,
                    'dateFormat'=>'yy-mm-dd',
                )
            ));
            ?>

<?php $this->endWidget(); ?>


0

#6 User is offline   DerekC 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 44
  • Joined: 09-December 09
  • Location:Europe

Posted 08 October 2012 - 10:18 AM

http://www.yiiframew...epicker-config/ seems to have solved this.
0

#7 User is offline   Nisanth thulasi 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 63
  • Joined: 10-July 12
  • Location:Kochi

Posted 08 July 2013 - 05:39 AM

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

						  	'showAnim'=>'fold',
						  	'dateFormat'=>'yy-mm-dd',
				      	),
				),

Thanks
Nisanth Thulasi
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users