diff options
| author | Patrick Seeger <pseeger@ccwn.org> | 2012-04-30 10:18:11 +0200 |
|---|---|---|
| committer | Patrick Seeger <pseeger@ccwn.org> | 2012-04-30 10:18:11 +0200 |
| commit | acec2b5dc35302147f9a9c73d837dce2f3f9958e (patch) | |
| tree | 2f88a3a657a9211331e1e63e056a089189bd0dd2 /protected/components/Html.php | |
| parent | 56593a21209f3ce55fe66d303dbe01b8e081778b (diff) | |
| parent | 148a216bba21cec1cbe07b60b5191791e0016d6f (diff) | |
Merge branch 'master' of ssh://proxy.ccwn.org:9044/home/ccwn/git-repos/admin.astaf.de
Diffstat (limited to 'protected/components/Html.php')
| -rw-r--r-- | protected/components/Html.php | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/protected/components/Html.php b/protected/components/Html.php index c4a246c..6c7df3c 100644 --- a/protected/components/Html.php +++ b/protected/components/Html.php @@ -1,6 +1,5 @@ <?php -class Html extends CHtml -{ +class Html extends CHtml { /** * Makes the given URL relative to the /image directory */ @@ -19,5 +18,21 @@ class Html extends CHtml public static function jsUrl($url) { return Yii::app()->baseUrl.'/js/'.$url; } + + public static function enumItem($model, $attribute) { + $attr = $attribute; + self::resolveName($model, $attr); + preg_match('/\((.*)\)/', $model->tableSchema->columns[$attr]->dbType, $matches); + foreach (explode(',', $matches[1]) as $value) { + $value = str_replace("'", null, $value); + $values[$value] = Yii::t('enumItem', $value); + } + + return $values; + } + + public static function enumDropDownList($model, $attribute, $htmlOptions = array()) { + return CHtml::activeDropDownList($model, $attribute, Html::enumItem($model, $attribute), $htmlOptions); + } } ?>
\ No newline at end of file |
