public function init()
 {
     parent::init();
     $this->_params = ArrayHelper::map(\app\models\ParamTypes::getAllParams(), 'id', 'name');
     if ($this->field == '') {
         throw new \yii\base\InvalidConfigException("Не задан параметр {$field}");
     }
 }
 public function afterLoadConfig()
 {
     $search = $replace = [];
     foreach (self::templateVars() as $tv => $conf) {
         $search[] = '{*' . $tv . '*}';
         $replace[] = '{' . $conf[0] . '}';
     }
     $params = ArrayHelper::map(\app\models\ParamTypes::getAllParams(), 'id', 'name');
     foreach ($params as $id => $name) {
         $search[] = '@' . $id . '@';
         $replace[] = '@' . $name . '@';
     }
     $this->itemTemplate = str_replace($search, $replace, $this->itemTemplate);
 }
Beispiel #3
0
use yii\helpers\Html;
use yii\helpers\Url;
use yii\helpers\ArrayHelper;
?>
<div>
    <div id="param-form">
		<?php 
echo Html::hiddenInput('table_id', $target::$tableId);
?>
		<?php 
echo Html::hiddenInput('item_id', $target->id);
?>
		<div class="row form-group">
			<div class="col-md-4">
			<?php 
echo Html::dropDownList('param_type', null, ArrayHelper::map(\app\models\ParamTypes::getAllParams(), 'id', 'name'), ['prompt' => 'Выберите параметр', 'class' => 'form-control']);
?>
			</div>
			<div class="col-md-7">
	    	<?php 
echo Html::textInput('param_value', null, ['class' => 'form-control', 'placeholder' => 'Введите значение']);
?>
	    	</div>
	    	<div class="col-md-1">
	    	<a href="#" id="add-param-btn" class="btn btn-primary"><i class="glyphicon glyphicon-plus"></i></a>
	    	</div>
    	</div>
    </div>
</div>
<div id="resource-params">
<div class="row"><div class="col-md-12">&nbsp;</div></div>