yii-auto-date-format Yii1 behavior to automatic convert date format

  1. yii-auto-date-format
  2. Instalation
  3. Usage

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',
	),
));
2 0
6 followers
356 downloads
Yii Version: 1.1
License: BSD-2-Clause
Category: Date and Time
Developed by: Misbahul D Munir
Created on: May 27, 2014
Last updated: 10 years ago

Downloads

show all

Related Extensions