Last active
September 30, 2015 08:38
-
-
Save jamband/1753872 to your computer and use it in GitHub Desktop.
Yii Framework: How to reduce the amount of the widget code.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php $this->widget('zii.widgets.jui.CJuiDatePicker', array( | |
'model' => $model, | |
'attribute' => $attribute, | |
'language' => 'ja', | |
'options' => array( | |
'dateFormat' => 'yy-mm-dd', | |
'yearRange' => '-70:+0', | |
'changeYear' => 'true', | |
'changeMonth' => 'true', | |
'showButtonPanel' => 'true', | |
'showOn' => 'both', | |
'buttonImage' => '/images/calendar.png', | |
'buttonImageOnly' => 'true', | |
), | |
)); ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php $this->widget('zii.widgets.jui.CJuiDatePicker', array( | |
'model' => $model, | |
'attribute' => 'birth', | |
'language' => 'ja', | |
'options' => array( | |
'dateFormat' => 'yy-mm-dd', | |
'yearRange' => '-70:+0', | |
'changeYear' => 'true', | |
'changeMonth' => 'true', | |
'showButtonPanel' => 'true', | |
'showOn' => 'both', | |
'buttonImage' => '/images/calendar.png', | |
'buttonImageOnly' => 'true', | |
), | |
)); ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
return array( | |
... | |
'components' => array( | |
... | |
'widgetFactory' => array( | |
'widgets' => array( | |
'CJuiDatePicker' => array( | |
'language' => 'ja', | |
'options' => array( | |
'dateFormat' => 'yy-mm-dd', | |
'yearRange' => '-70:+0', | |
'changeYear' => 'true', | |
'changeMonth' => 'true', | |
'showButtonPanel' => 'true', | |
'showOn' => 'both', | |
'buttonImage' => '/images/calendar.png', | |
'buttonImageOnly' => 'true', | |
), | |
), | |
), | |
), | |
... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
Yii::import('zii.widgets.jui.CJuiDatePicker'); | |
/** | |
* MyDatePicker class file. | |
*/ | |
class MyDatePicker extends CJuiDatePicker | |
{ | |
/** | |
* @see CJuiDatePicker::language | |
*/ | |
public $language = 'ja'; | |
/** | |
* @see CJuiWidget::options | |
*/ | |
public $options = array( | |
'dateFormat' => 'yy-mm-dd', | |
'yearRange' => '-70:+0', | |
'changeYear' => 'true', | |
'changeMonth' => 'true', | |
'showButtonPanel' => 'true', | |
'showOn' => 'both', | |
'buttonImage' => '/images/calendar.png', | |
'buttonImageOnly' => 'true', | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment