how to link jui date picker to active model ?

Hi all,

I have a problem with jui datepicker widget.

I want to create it as an active component, can I do that?

if so, how to ?

this is my jui datepicker code :




<?php

$this->widget('application.extensions.jui.EDatePicker',

              array(

                    //$model,

		    'name'=>'tgl_mulai',

                    'language'=>'es',

                    'mode'=>'imagebutton',

                    'theme'=>'dot-luv',

                    'value'=>date('Y-m-d'),

                    //'options'=>array('beforeShowDay'=>'$.datepicker.noWeekends'),

                    'htmlOptions'=>array('size'=>10)

                   )

             );

 

?>



and this is what it be in text field :




<?php echo CHtml::activeTextField($model,'tgl_mulai'); ?>



I want to change the textfield using jui date picker, with parameter $model.

Please help, thanks you.

Hi,

try date picker from ZII CJiuDatePicker. Look at model property.

thanks for you reply qwerty,

could you let me know, where to download zii extension ?

I have checked in this link http://code.google.com/p/zii/source/checkout but find nothing.

Thank you.

ZII is in 1.1.0 Yii version (download section)

OK Thank you.

I got teh zii,

then, how to put $model as a parameter in the zii jui datepicker ?

That is what I want to know.

I have read the documentation and try this code :




$this->widget('zii.widgets.jui.CJuiDatePicker', array(

    'name'=>'tgl_mulai',

	'attribute'=>'tgl_mulai',

	'model'=>$model,

	//'controller'=>$controller,

	// additional javascript options for the date picker plugin

    'options'=>array(

        'showAnim'=>'fold',

    ),

    'htmlOptions'=>array(

       'style'=>'height:20px;','name'=>'tgl_mulai',

    ),

));




I added $model as parameter, but still, this not solve my problem, to link this widget to my model.

any help will high appreciated. Thanks.

for example, $Auftrag->von should be




<?php $this->widget('zii.widgets.jui.CJuiDatePicker', 

array('name'=>'Auftrag[von]', 

'language' => 'de', 

'value' => $model->von,

  'options' => array('changeMonth' => 'true',

 'changeYear' => 'true',

 'showButtonPanel' => 'true', 

'constrainInput' => 'false'))); ?>




Thank you very much ! it’s works !

[font=“Arial Black”][size=“4”]Thank you very much too! that it’s works ! [/size][/font] :rolleyes:

I think that you can also do:




<?php $this->widget('zii.widgets.jui.CJuiDatePicker', 

array(

'language' => 'de', 

'model' => $model,

'attribute'=>'von'

  'options' => array('changeMonth' => 'true',

 'changeYear' => 'true',

 'showButtonPanel' => 'true', 

'constrainInput' => 'false'))); ?>






thank you zaccaria, that work too.:rolleyes:

but when i was trying to implement on the _search form that generate by gii, there be no result.

this my _search form




<?php $form=$this->beginWidget('CActiveForm', array(

	'action'=>Yii::app()->createUrl($this->route),

	'method'=>'get',

)); ?>


  	<div class="row">

		<?php echo $form->label($model,'create_time'); ?>

    	<?php 

        	$this->widget('zii.widgets.jui.CJuiDatePicker', array(

            	'model'=>$model,

            	'attribute'=>'create_time',

            	'options'=>array(

                	'showAnim'=>'fold',

                	'dateFormat'=>'dd M yy',

            	),

        	));

    	?>

	</div>


<div class="row buttons">

		<?php echo CHtml::submitButton('Search'); ?>

</div>

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

</div><!-- search-form -->



this code on my model.




public function search()

	{		

		$criteria=new CDbCriteria;


		$criteria->compare('id',$this->id);

		$criteria->compare('sum',$this->sum);


    	// this data from Date Picker

		$criteria->compare('create_time', strtotime($this->create_time));


		return new CActiveDataProvider(get_class($this), array(

			'criteria'=>$criteria,

		));

	}



What is your problem? It is not searching?

Check if in the model you have the value (in search, echo $this->create_time) and if in post there is the value (somewhere, echo $_POST[‘modelName’][‘create_time’]).

If you have the post value but not the value in the model, 99% you have to add create_time to the list of safe attributes ‘on’=>‘search’

i have create_time to the list of safe attributes ‘on’=>‘search’

and still have no results, but from your explanation, i am sure no mistake on my code.

so i checking on beforeSave() function have i made




if($this->isNewRecord)

{

	$this->create_time=$this->update_time=time();

}



and on my _search i use




$criteria->compare('create_time',strtotime($this->create_time));



of course there will be never match anything ;D

now on my beforeSave()




$dateNow = date("d F Y", time());

if($this->isNewRecord)

{

	$this->create_time=$this->update_time=strtotime($dateNow);

}



sorry, i think, i must read PHP manual again.

[size=“5”]thank you very much zaccaria[/size] :D