Yii Framework Forum: default value for Cjuidatetimepicker - Yii Framework Forum

Jump to content

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

default value for Cjuidatetimepicker Rate Topic: -----

#1 User is offline   richa 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 21
  • Joined: 21-July 11

Posted 01 November 2011 - 06:42 AM

Hi all,



I am using CJuiDateTimePicker in my code. I want to keep a default value. Can anybody tell me how to do this?
my code is:

<?php Yii::import('application.extensions.CJuiDateTimePicker.CJuiDateTimePicker');
    $this->widget('CJuiDateTimePicker',array(
        'model'=>$model, //Model object
	
        'attribute'=>'['.$i.']timein', //attribute name

                'mode'=>'time', //use "time","date" or "datetime" (default)
'value'=>'08:00:00'////////////// this does not work
        'options'=>array() // jquery plugin options
    ));
?>


Thanks in advance
0

#2 User is offline   codesutra 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 596
  • Joined: 15-March 11
  • Location:India

Posted 01 November 2011 - 07:07 AM

View Postricha, on 01 November 2011 - 06:42 AM, said:

Hi all,



I am using CJuiDateTimePicker in my code. I want to keep a default value. Can anybody tell me how to do this?
my code is:

<?php Yii::import('application.extensions.CJuiDateTimePicker.CJuiDateTimePicker');
    $this->widget('CJuiDateTimePicker',array(
        'model'=>$model, //Model object
	
        'attribute'=>'['.$i.']timein', //attribute name

                'mode'=>'time', //use "time","date" or "datetime" (default)
'value'=>'08:00:00'////////////// this does not work
        'options'=>array() // jquery plugin options
    ));
?>


Thanks in advance



You should spend some time Here

Hope this will definitely help you.And please define a default formate in option array and then ty to assign a default value.Might be this will work for you.
CodeSutra
0

#3 User is offline   richa 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 21
  • Joined: 21-July 11

Posted 01 November 2011 - 07:49 AM

View Postjayant, on 01 November 2011 - 07:07 AM, said:

You should spend some time Here

Hope this will definitely help you.And please define a default formate in option array and then ty to assign a default value.Might be this will work for you.




hey jayant,
thanks for the quick reply..
Your suggestion helped but not fully. I can set defalut value by using the parameter hour, it reflects on the slider but i want the value to be shown in the text box. Is this possible?

Thanks again
0

#4 User is offline   codesutra 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 596
  • Joined: 15-March 11
  • Location:India

Posted 01 November 2011 - 07:53 AM

View Postricha, on 01 November 2011 - 07:49 AM, said:

hey jayant,
thanks for the quick reply..
Your suggestion helped but not fully. I can set defalut value by using the parameter hour, it reflects on the slider but i want the value to be shown in the text box. Is this possible?

Thanks again



would you please show me your current code snippet.so that i can figure out what the prob here..
CodeSutra
0

#5 User is offline   richa 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 21
  • Joined: 21-July 11

Posted 02 November 2011 - 02:47 AM

View Postjayant, on 01 November 2011 - 07:53 AM, said:

would you please show me your current code snippet.so that i can figure out what the prob here..



hey jayant,

here is my code
<?php Yii::import('application.extensions.CJuiDateTimePicker.CJuiDateTimePicker');
    $this->widget('CJuiDateTimePicker',array(
        'model'=>$model, //Model object
	
        'attribute'=>'['.$i.']timein', //attribute name

                'mode'=>'time', //use "time","date" or "datetime" (default)
        'options'=>array('timeFormat'=>'hh:mm:ss','hour'=>'8'

) // jquery plugin options
    ));
?>



As u can see i have set the hour to 8 which shows on the slider but it doesnt display in the text field. I need the time to be displayed in the text field without first selecting the time.
0

#6 User is offline   codesutra 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 596
  • Joined: 15-March 11
  • Location:India

Posted 02 November 2011 - 03:37 AM

View Postricha, on 02 November 2011 - 02:47 AM, said:

hey jayant,

here is my code
<?php Yii::import('application.extensions.CJuiDateTimePicker.CJuiDateTimePicker');
    $this->widget('CJuiDateTimePicker',array(
        'model'=>$model, //Model object
	
        'attribute'=>'['.$i.']timein', //attribute name

                'mode'=>'time', //use "time","date" or "datetime" (default)
        'options'=>array('timeFormat'=>'hh:mm:ss','hour'=>'8'

) // jquery plugin options
    ));
?>



As u can see i have set the hour to 8 which shows on the slider but it doesnt display in the text field. I need the time to be displayed in the text field without first selecting the time.


Well try this and let me know
<?php Yii::import('application.extensions.CJuiDateTimePicker.CJuiDateTimePicker');
    $this->widget('CJuiDateTimePicker',array(
        'name'=>'define a model attribute here', // like Event[start_date]
        'model'=>$model,
        'value'=>"define a value here",
	 //  'attribute'=>'['.$i.']timein', //attribute name

                'mode'=>'time', //use "time","date" or "datetime" (default)
        'options'=>array('timeFormat'=>'hh:mm:ss','hour'=>'8'

) // jquery plugin options
    ));
?>



might be this will work.
CodeSutra
0

#7 User is offline   i_one 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 13-January 12

Posted 12 March 2012 - 09:54 PM

View Postjayant, on 02 November 2011 - 03:37 AM, said:

Well try this and let me know
<?php Yii::import('application.extensions.CJuiDateTimePicker.CJuiDateTimePicker');
    $this->widget('CJuiDateTimePicker',array(
        'name'=>'define a model attribute here', // like Event[start_date]
        'model'=>$model,
        'value'=>"define a value here",
	 //  'attribute'=>'['.$i.']timein', //attribute name

                'mode'=>'time', //use "time","date" or "datetime" (default)
        'options'=>array('timeFormat'=>'hh:mm:ss','hour'=>'8'

) // jquery plugin options
    ));
?>



might be this will work.



Hey jayant,

Thanks for your support
0

#8 User is offline   csibug 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 14-February 09
  • Location:Budapest

Posted 24 April 2012 - 03:17 PM

hi all,

i have some problem regarding the CJuiDateTimePicker extension.
i would like to update an existing record. on the form, the textbox is filled with the current value of the model attribute: 2012-03-29 12:25:00
if i click on the textbox, the CJuiDateTimePicker opens, but not with the proper datetime. only the time part is correct, the selected date is the current (2012-04-24), not the proper value of the record (2012-03-29).

Here is the fragment of my view:

<?php Yii::import('application.extensions.CJuiDateTimePicker.CJuiDateTimePicker');
$this->widget('CJuiDateTimePicker',array(
'model'=>$model, //Model object
'attribute'=>'begin_date', //attribute name
'mode'=>'datetime', //use "time","date" or "datetime" (default)
'options'=>array('dateFormat'=>'yy-mm-dd', 'timeFormat'=>'hh:mm:ss') // jquery plugin options
));
?>
0

#9 User is offline   amorangi 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 29
  • Joined: 01-May 09

Posted 26 April 2012 - 12:23 AM

Same problem - the time part is set correctly, but the month stays on the current month (right now, that's April 2012), rather than display the date contained in the model (eg May 2008).

Has anyone found a solution to this?
0

#10 User is offline   pundit 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 19-November 12

Posted 19 November 2012 - 11:16 AM

View Postamorangi, on 26 April 2012 - 12:23 AM, said:

Same problem - the time part is set correctly, but the month stays on the current month (right now, that's April 2012), rather than display the date contained in the model (eg May 2008).

Has anyone found a solution to this?


I spent half a day trying to figure this out and finally found a solution. The JS files are out of date and have to be updated. I can't post links as my account is too new (couldn't post a comment in the extension page either, a very annoying way to prevent spam), so google "yii improving datetimepicker" for the solution at Hollow Developers, or go straight to Trent Richardson's jQUery-Timepicker-Addon page at Github and download them from there.
0

#11 User is offline   gdang 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 37
  • Joined: 20-August 11
  • Location:Venice

Posted 29 December 2012 - 12:18 PM

A little late but I resolved today the problem.

I must put the value on the field on the update, than before the render I wrote:

		$model->date = date_create($model->date)->format('d/m/Y H:i'); 
		
		$this->render('update',array(
			'model'=>$model,
		));


WHY?

because on the extension class on line 37:

		if($this->hasModel())
			echo CHtml::activeTextField($this->model,$this->attribute,$this->htmlOptions);
		else
			echo CHtml::textField($name,$this->value,$this->htmlOptions);

We have an activeTextField if we pass one model as parameter and I wrote on google: activeTextField change default value and I found this solution.

Sometimes when I feel sick I try to write synthoms on google but normally don't work very well... Maybe there are better solutions :lol:
I'm beautiful and I dance well!
0

Share this topic:


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

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