<?php } ?> </div> <div class="form-group"> <?php echo $form->labelEx($model, 'title', array('class'=>'col-lg-2 col-md-12 col-sm-12 control-label')); ?> <div class="col-lg-10 col-md-12 col-sm-12"> <?php echo $form->textField($model,'title',array('class'=>'form-control','maxlength'=>255)); ?> </div> </div> <!-- / .form-group --> <div class="form-group"> <?php echo $form->label($model, 'group_id', array('class'=>'col-lg-2 col-md-12 col-sm-12 control-label')); ?> <div class="col-lg-10 col-md-9 col-sm-8"> <?php echo $form->dropDownList( $model, 'group_id', EavOptionsGroup::model()->getFormattedList(), array( 'encode'=>false, 'empty'=>'Выберите группу', 'class'=>'form-control' )); ?> </div> </div> <div class="form-group"> <?php echo $form->label($model, 'name', array('class'=>'col-lg-2 col-md-12 col-sm-12 control-label')); ?> <div class="col-lg-10 col-md-12 col-sm-12"> <?php echo $form->textField($model,'name',array('class'=>'form-control','maxlength'=>255)); ?> </div> </div> <!-- / .form-group -->
public function actionDeleteGroup($id) { $error = 'Ошибка'; $model=EavOptionsGroup::model()->findByPk($id); if(!$model) throw new CHttpException(404,'The requested page does not exist.'); $attrs = $model->groupAttributes; $check = null; if($attrs){ foreach ($attrs as $attr) { $check = EavOptions::model()->find(array( 'condition'=>'title=:title and group_id is null', 'params'=>array(':title'=>$attr->title) )); if(!$check) $check = EavOptions::model()->find(array( 'condition'=>'name=:name and group_id is null', 'params'=>array(':name'=>$attr->name) )); if($check) break; } } if(!$check){ $model->delete(); echo CJSON::encode(array('success'=>true)); Yii::app()->end(); } else { $error = 'Нельзя удалить, т.к. имеются атрибуты с похожим названием. Проверьте атрибут '.$check->title; } echo CJSON::encode(array('success'=>false, 'message'=>$error)); Yii::app()->end(); }
'encode'=>false, 'empty'=>Yii::t('site', 'None'), 'class'=>'form-control' )); ?> </div> </div> <div class="row"> <?php $tree = []; $selectedAttributes = []; $model->refresh(); foreach ($model->typeAttributes as $attribute) { $selectedAttributes[] = $attribute->id; } foreach ((array)EavOptionsGroup::model()->findAll(array('order'=>'name')) as $group) { $items = []; $groupHasNotSelectedAttribute = false; $groupItems = (array)$group->groupAttributes; foreach ($groupItems as $item) { $selected = in_array($item->id, $selectedAttributes); if (!$selected) { $groupHasNotSelectedAttribute = true; } $items[] = ['text' => CHtml::tag('div', ['class' => 'checkbox treecheck'], CHtml::label(CHtml::checkBox('attributes[]', $selected, ['value' => $item->id]) . $item->title, null))]; } $tree[] = [ 'text' => CHtml::tag( 'div', ['class' => 'checkbox treecheck'], CHtml::label(CHtml::checkBox('', count($groupItems) && !$groupHasNotSelectedAttribute, ['class' => 'group-checkbox']) . $group->name, null)