yii-auto-date-format ¶
Yii1 behavior to automatic convert date format
Instalation ¶
Download from this yii-auto-date-format and extract to your extension directory.
Usage ¶
On your ActiveRecord class, add to method behaviors()
:
function behaviors()
{
return array(
'AutoDateFormat' => array(
'class' => 'ext.MdmAutoDateBehavior',
'logicalFormat' => 'd-m-Y', // optional, default d-m-Y
'physicalFormat' => 'Y-m-d', // optional, default Y-m-d
'attributes' => array(
'orderDate' => 'order_date', // mapping attribute from logical to physical filed.
),
),
...
);
}
Then, for this AR, use attribute orderDate
instead of order_date
.
$model->orderDate = '27-05-2014';
equivalent with
$model->order_date = '2014-05-27';
on your form
$form->widget('zii.widgets.jui.CJuiDatePicker', array(
'model' => $model,
'attribute' => 'orderDate',
'options' => array(
'showAnim' => 'fold',
'dateFormat' => 'dd-mm-yy',
),
'htmlOptions' => array(
'style' => 'height:20px;',
'size' => '12',
),
));
I was try but not save still 00-00-0000
my models :
public function behaviors() { return array( 'AutoDateFormat' => array( 'class' => 'ext.MdmAutoDateBehavior', 'logicalFormat' => 'd-m-Y', // optional, default d-m-Y 'physicalFormat' => 'Y-m-d', // optional, default Y-m-d 'attributes' => array( 'curkmkd' => 'CUR_KMKD', // mapping attribute from logical to physical filed. ), ), ); }
Please tell me, help n correct me.
@masdib.banget
How do you assign to
curkmkd
field. as mass assigment or individual assignment?try to add
curkmkd
to model rules.contact me at gtalk misbahuldmunir@gmail.com or fb misbahul.d.munir
Success
Yes, i make a rule and saved.
Usefull.
Thanks Misbahul D Munir
Nice extensions!!
So far works good, keep it up
@myrazel
Thanks... if any trouble or something. Fill free to ask or submit issue.
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.