Пример #1
0
 /**
  * Display the widget
  * @see CWidget::run()
  */
 public function run()
 {
     //style="width:'.($this->width-$this->titlewidth-28).'px;"
     //$content = ob_get_clean();
     $models = EavFields::find()->All();
     //array('order' => 'name')
     $list = ArrayHelper::map($models, 'id', 'name');
     $htmlOptions = array('class' => 'eav');
     $select = Html::dropDownList($this->name . '_E_', 0, $list, $htmlOptions);
     $select = str_replace("\n", "", $select);
     $select = str_replace($this->name . '_E_', "propertiesE['+uid+']", $select);
     return $this->render("eavProp", ["name" => $this->name, "select" => $select, "attr" => $this->attr, "model" => $this->model]);
 }
Пример #2
0
use kartik\select2\Select2;
use app\models\EavFields;
?>

	<?php 
echo $form->errorSummary($model);
?>

	<?php 
echo $form->field($model, 'name');
?>



<?php 
echo $form->field($model, 'eavType')->widget(Select2::classname(), ['data' => \yii\helpers\ArrayHelper::map(EavFields::getTypes(), 'id', 'name')]);
?>
	<?php 
//\yii\helpers\ArrayHelper::map(, 'id', 'name');
//echo $form->field($model,'eavType',array('class'=>'span5','maxlength'=>255));
?>

	<?php 
echo $form->field($model, 'min');
?>

	<?php 
echo $form->field($model, 'max');
?>

	<div class="form-actions">
Пример #3
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = EavFields::findOne($id);
     if ($model === null) {
         throw new \yii\web\HttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Пример #4
0
 * 
 * All Rights Reserved.
 * ********************************************************************************** */
$script1 = "\n    function deleteEav(str){\n   \t\t\t\$('#properties_V_'+str).parent().parent().remove();\n   \t\t\t//\$('#properties_V_'+str).parent().parent().css('background', 'yellow');\n    \t\t//alert(str);\n    \t}\n    \t\t\n    \tfunction newEav(){\n    \t\tvar uid = \$('#properties_eav_I').val();\n                var input1 = '{$select}';\n                var input2 = '<input id=\"properties_V_'+uid+'\" type=\"text\" value=\"\" name=\"propertiesV['+uid+']\" />';\n    \t\tvar template = '<tr><td>'+input1+'</td><td>'+input2+'</td><td><a href=\\'javascript:deleteEav(\"'+uid+'\");\\'><i class=\"glyphicon glyphicon-remove\"></i></a></td></tr>';\n\n                \$('#eavProp').append(template);\n    \t}\n\n    ";
$script = "\n    \n   \t\t\n            \n        \$(document).on('change','.eav',\n            function(e) {\n                console.log(\$(this).val());\n                console.log(this.id.replace('AccountseavE[','').replace(']',''));\n                //\$('#accType').val(this.id.replace(',''));\n                \n                var href = '" . \yii\helpers\BaseUrl::base() . '/eavFields/ajax' . "/' + \$(this).val();\n                var td=\$(this).parent().next();\n                //console.log(this);\n                \n                \$.post(href, function(data) {\n                console.log(td);\n                    data=data.replace('Settings_','properties_V_').replace('_value','');\n                    data=data.replace('Settings[','propertiesV[').replace('[value]','');\n                   td.html(data);//data;\n                    \n                    \n                });\n                // console.log(data.responseText);\n                //\$(this).parent().next().html(data.responseText);//.next();\n\n                \n                //window.location ='/'+ \$('#accType').val();\n                //return false;\n                \n            }\n        );\n    ";
$this->registerJs($script, \yii\web\View::POS_READY);
$this->registerJs($script1, \yii\web\View::POS_END);
echo '
		<table class="table" >
			<tr>
				
				<td>' . Yii::t('app', 'property') . '</td>
				<td>' . Yii::t('app', 'value') . '</td>
				<td>' . Yii::t('app', 'action') . '</td>
			</tr>
			<tbody id="eavProp">
		';
//var_dump($attr);
//exit;
foreach ($attr as $att) {
    //$this->attributeField.', '.$this->valueField
    $key = $att[$model->attributeField];
    $value = $att[$model->valueField];
    $eav = \app\models\EavFields::findOne($key);
    $name1 = "NA";
    if (!is_null($eav)) {
        $name1 = $eav->name;
    }
    echo "<tr>\n\t\t\t\t\n\t\t\t\t<td><input id=\"properties_E_{$key}\" type='hidden' value='{$key}' name=\"propertiesE[{$key}]\" />{$name1}</td>\n\t\t\t\t<td><input id=\"properties_V_{$key}\" type='text' value='{$value}' name=\"propertiesV[{$key}]\" /></td>\n\t\t\t\t<td>\n                                        <a href='javascript:deleteEav(\"{$key}\");'><i class='glyphicon glyphicon-remove'></i></a>\n\t\t\t\t\t<!--/**<a href='javascript:editEav(\"{$key}\");'><img src='" . \yii\helpers\BaseUrl::base() . "/assets/5ac26951/gridview/update.png'></a>**/-->\n\t\t\t\t</td>\n\t\t\t</tr>";
}
echo "<tbody>\n\t\t\t\t<tfoot>\n\t\t\t\t\t<tr class='sum'>\n\t\t\t\t\t\n\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t<td><input id='properties_eav_I' type='hidden' value='0' name='eavI' /><a href='javascript:newEav();'>" . Yii::t('app', 'Add new field') . "</a></td>\n\t\t\t\t\t</tr>\n\t\t\t\t</tfoot>\n\t\t\t</table>\n\t\t\n\t\t\n\t\t";