Exemple #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::model()->findAll(array('order' => 'name'));
        $list = CHtml::listData($models, 'id', 'name');
        $htmlOptions = array('class' => 'eav');
        $select = CHtml::dropDownList($this->name . '_E_', 0, $list, $htmlOptions);
        $select = str_replace("\n", "", $select);
        $select = str_replace($this->name . '_E_', $this->name . "eavE['+uid+']", $select);
        $script = "\n    \n   \t\tfunction deleteEav(str){\n   \t\t\t\$('#{$this->name}_V_'+str).parent().parent().remove();\n   \t\t\t//\$('#{$this->name}_V_'+str).parent().parent().css('background', 'yellow');\n    \t\t//alert(str);\n    \t}\n    \t\t\n    \tfunction newEav(){\n    \t\tvar uid = \$('#{$this->name}_eav_I').val();\n                var input1 = '{$select}';\n                var input2 = '<input id=\"{$this->name}_V_'+uid+'\" type=\"text\" value=\"\" name=\"{$this->name}eavV['+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        \$('.eav').live('change',\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::app()->createUrl('/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_','{$this->name}_V_').replace('_value','');\n                    data=data.replace('Settings[','{$this->name}eavV[').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    ";
        Yii::app()->clientScript->registerScript('eav', $script, CClientScript::POS_HEAD);
        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">
		';
        foreach ($this->attr as $key => $value) {
            $name = EavFields::model()->findByPk($key)->name;
            echo "<tr>\n\t\t\t\t\n\t\t\t\t<td><input id=\"{$this->name}_E_{$key}\" type='hidden' value='{$key}' name=\"{$this->name}eavE[{$key}]\" />{$name}</td>\n\t\t\t\t<td><input id=\"{$this->name}_V_{$key}\" type='text' value='{$value}' name=\"{$this->name}eavV[{$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::app()->request->baseUrl . "/assets/5ac26951/gridview/update.png'></a>**/-->\n\t\t\t\t</td>\n\t\t\t</tr>";
        }
        echo '<tbody>
				<tfoot>
					<tr class="sum">
					
						<td></td>
						<td></td>
						<td><input id="' . $this->name . '_eav_I" type="hidden" value="0" name="eavI" /><a href=\'javascript:newEav();\'>' . Yii::t('app', 'Add new field') . '</a></td>
					</tr>
				</tfoot>
			</table>
		
		
		';
    }
Exemple #2
0
$model->min = 0;
$model->max = 255;
?>

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

	<?php 
echo $form->textFieldRow($model, 'name', array('class' => 'span5', 'maxlength' => 255));
?>



<?php 
echo $form->dropDownListRow($model, 'eavType', CHtml::listData(EavFields::model()->getTypes(), 'id', 'name'));
?>
	<?php 
//CHtml::listData(, 'id', 'name');
//echo $form->textFieldRow($model,'eavType',array('class'=>'span5','maxlength'=>255));
?>

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

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

	<div class="form-actions">
 /**
  * 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::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Exemple #4
0






<?php 
$this->beginWidget('zii.widgets.jui.CJuiDialog', array('id' => 'addnew', 'options' => array('title' => Yii::t('app', 'Add new field'), 'autoOpen' => false, 'width' => '600px')));
//bootstrap.widgets.TbModal
$form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array('id' => 'newField', 'htmlOptions' => array('class' => 'well'), 'action' => array('SaveSub', 'id' => $model->id)));
?>

<div class="modal-body">
<?php 
$models = EavFields::model()->findAll(array('order' => 'name'));
$list = CHtml::listData($models, 'id', 'name');
$htmlOptions = array();
$select = CHtml::dropDownList(ucfirst($this->id) . 'Item[eavFields_id]', 0, $list, $htmlOptions);
echo $select;
?>
    <input type='hidden' value='<?php 
echo $model->id;
?>
' name='<?php 
echo ucfirst($this->id);
?>
Item[AccTemplate_id]'>

</div>
Exemple #5
0
//print_r($model->items);
//Yii::$app->end();
echo app\widgets\GridView::widget(array('id' => 'acc-templateItem-grid', 'dataProvider' => $items->search(), 'filter' => $items, 'columns' => array(array('name' => 'eavFields_id', 'value' => '$data->EavFields->name'), array('class' => 'yii\\grid\\ActionColumn', 'template' => '{remove}', 'buttons' => array('remove' => array('label' => '<i class="glyphicon glyphicon-remove"></i>', 'url' => '$data->id', 'options' => array('onclick' => 'deleteTempItm(this);return false;')))))));
app\widgets\MiniForm::end();
?>


<?php 
echo \yii\jui\Dialog::begin(array('id' => 'addnew', 'options' => array('title' => Yii::t('app', 'Add new field'), 'autoOpen' => false, 'width' => '600px')));
//bootstrap.widgets.TbModal
$form = kartik\form\ActiveForm::begin(array('id' => 'newField', 'options' => array('class' => 'well'), 'action' => array('SaveSub', 'id' => $model->id)));
?>

<div class="modal-body">
<?php 
$models = EavFields::find()->All(array('order' => 'name'));
$list = \yii\helpers\ArrayHelper::map($models, 'id', 'name');
$options = array();
$select = \yii\helpers\Html::dropDownList(ucfirst($this->id) . 'Item[eavFields_id]', 0, $list, $options);
echo $select;
?>
    <input type='hidden' value='<?php 
echo $model->id;
?>
' name='<?php 
echo ucfirst($this->id);
?>
Item[ItemTemplate_id]'>

</div>
Exemple #6
0






<?php 
echo \yii\jui\Dialog::begin(array('id' => 'addnew', 'options' => array('title' => Yii::t('app', 'Add new field'), 'autoOpen' => false, 'width' => '600px')));
//bootstrap.widgets.TbModal
$form = kartik\form\ActiveForm::begin(array('id' => 'newField', 'action' => array('SaveSub', 'id' => $model->id)));
?>

<div class="modal-body">
<?php 
$models = EavFields::find()->All();
//array('order' => 'name')
$list = \yii\helpers\ArrayHelper::map($models, 'id', 'name');
$options = array();
$select = \yii\helpers\Html::dropDownList(ucfirst($this->id) . 'Item[eavFields_id]', 0, $list, $options);
echo $select;
?>
    <input type='hidden' value='<?php 
echo $model->id;
?>
' name='<?php 
echo ucfirst($this->id);
?>
Item[AccTemplate_id]'>

</div>