Commit 23a521ec authored by Tobias Munk's avatar Tobias Munk

removed logic from model-extended template, see also #170

parent efcd0999
Pipeline #13725 passed with stages
in 1 minute and 56 seconds
......@@ -46,63 +46,4 @@ public function behaviors()
]
);
}
public static $listBoxData;
<?php if (isset($translation)): ?>
/**
* create array for listbox
* @param boolean $forValue list hidded elements
* @return type
*/
public static function forListbox($forValue = false)
{
if (self::$listBoxData){
return self::$listBoxData;
}
$query = self::find()
->select('`<?=$tableName?>`.`<?=$tableSchema->primaryKey[0]?>` `id`, `lang`.`<?=$translation['fields'][0]?>` `name`')
->leftJoin('`<?=$translation['language_table']?>` lang ', '<?=$tableName?>.`<?=$tableSchema->primaryKey[0]?>` = lang.<?=$tableName?>_id and lang.language = "'.Yii::$app->language.'" ')
->orderBy('`lang`.`<?=$translation['fields'][0]?>`');
// if (!$forValue) {
// $query->where(['hidded' => 0]);
// }
$rows = $query->asArray()->all();
return self::$listBoxData = \yii\helpers\ArrayHelper::map($rows,'id', 'name');
}
<?php endif; ?>
<?php if (!isset($translation)): ?>
/**
* create array for listbox
* @param boolean $forValue list hidded elements
* @return type
*/
public static function forListbox($forValue = false)
{
if (self::$listBoxData){
return self::$listBoxData;
}
$query = self::find()
->select('`<?=$tableSchema->primaryKey[0]?>` `id`, `name`')
//->where(['hidded' => 0])
->orderBy('`name`');
// if (!$forValue) {
// $query->where(['hidded' => 0]);
// }
$rows = $query->asArray()->all();
return self::$listBoxData = \yii\helpers\ArrayHelper::map($rows,'id', 'name');
}
<?php endif; ?>
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment