Page 1 of 1
CMaskedTextField Can I use CMaskedTextField to have a hh:mm format?
#1
Posted 03 December 2010 - 08:34 AM
Hi,
How can I use CMaskedTextField to format a Date/Time database field (MySQL) to "hh:mm"?
Tks
BSC
How can I use CMaskedTextField to format a Date/Time database field (MySQL) to "hh:mm"?
Tks
BSC
#3
Posted 04 December 2010 - 11:49 AM
Can you please show me an example of the full code line....
Tks
Tks
#4
Posted 22 November 2011 - 06:17 AM
BSC, on 04 December 2010 - 11:49 AM, said:
Can you please show me an example of the full code line....
Tks
Tks
<?php
$this->widget('CMaskedTextField', array(
'model' => $model,
'value' => $model->isNewRecord ? $model->your_attribute_name : '',
'attribute' => 'your_attribute_name',
'mask' => '99:99:99',
'htmlOptions' => array('size' => 10)
)
);
?>
#5
Posted 26 November 2011 - 10:33 AM
I bit off-topic and just guessing, as I never used CMaskedTextEdit.
But since it should be similar to other model-related, active form elements, then you don't have to provide value, the way you use value parameter in your example. It should work fine, with model and attribute parameters set, in both situations (editing existing one or creating new model).
If I'm not mistaken, for widgets like this (and many more - for example CGridView/CDetailView columns) you provide either value or model+attribute, not both at the same time.
But since it should be similar to other model-related, active form elements, then you don't have to provide value, the way you use value parameter in your example. It should work fine, with model and attribute parameters set, in both situations (editing existing one or creating new model).
If I'm not mistaken, for widgets like this (and many more - for example CGridView/CDetailView columns) you provide either value or model+attribute, not both at the same time.
Proud Cookbook author, though still learning powerful Yii! :] See my generic profile for more information. Cheers!
#6
Posted 12 September 2012 - 08:32 AM
cactork, on 22 November 2011 - 06:17 AM, said:
<?php
$this->widget('CMaskedTextField', array(
'model' => $model,
'value' => $model->isNewRecord ? $model->your_attribute_name : '',
'attribute' => 'your_attribute_name',
'mask' => '99:99:99',
'htmlOptions' => array('size' => 10)
)
);
?>
I did follow the instructions but not effective!
I want set max hour <= 24 and minute <= 59.
#8
Posted 25 March 2013 - 08:17 PM
Mao Danh, on 12 September 2012 - 08:32 AM, said:
I did follow the instructions but not effective!
I want set max hour <= 24 and minute <= 59.
I want set max hour <= 24 and minute <= 59.
<?php
$this->widget('CMaskedTextField', array(
'model' => $model,
'value' => $model->isNewRecord ? $model->your_attribute_name : '',
'attribute' => 'your_attribute_name',
'mask' => '23:59:59',
'htmlOptions' => array('size' => 10)
)
);
?>
I think this is what he was looking for... Which would allow up to 23:59:59, but I don't see how you'd be able to do 24 without going to 24:59:59 on the inputs (without writing javascript)
Share this topic:
Page 1 of 1

Help












