public function actionGroup($id = null) { if ($id === null) { $model = new PropertyGroup(); } else { $model = PropertyGroup::findById($id); } if ($model->load(\Yii::$app->request->post()) && $model->validate()) { $save_result = $model->save(); if ($save_result) { Yii::$app->session->setFlash('success', Yii::t('app', 'Record has been saved')); $returnUrl = Yii::$app->request->get('returnUrl', ['/backend/properties/index']); switch (Yii::$app->request->post('action', 'save')) { case 'next': return $this->redirect(['/backend/properties/group', 'returnUrl' => $returnUrl]); case 'back': return $this->redirect($returnUrl); default: return $this->redirect(['/backend/properties/group', 'id' => $model->id, 'returnUrl' => $returnUrl]); } } else { Yii::$app->session->setFlash('error', Yii::t('app', 'Cannot save data')); } } $searchModel = new Property(); $searchModel->property_group_id = $model->id; $dataProvider = $searchModel->search($_GET); return $this->render('group', ['model' => $model, 'dataProvider' => $dataProvider, 'searchModel' => $searchModel]); }
</div> <div class="form-group"> <?php echo Html::a(Yii::t('app', 'Your orders'), ['/shop/orders/list']); ?> </div> </div> <div class="col-md-6 col-sm-12"> <?php foreach ($propertyGroups as $groupId => $properties) { ?> <?php if (count($properties) > 0) { $group = \app\models\PropertyGroup::findById($groupId); if (intval($group->hidden_group_title) == 0) { echo Html::tag('h2', $group->name); } $properties = app\models\Property::getForGroupId($groupId); foreach ($properties as $prop) { $property_values = $model->getPropertyValuesByPropertyId($prop->id); echo $prop->handler($form, $model->getAbstractModel(), $property_values, 'frontend_edit_view'); } } ?> <?php } ?>
use yii\helpers\Html; /* @var $form \kartik\widgets\ActiveForm */ /* @var $fields array */ /* @var \app\modules\data\models\ImportModel $model */ /* @var $availablePropertyGroups */ ?> <fieldset> <legend><?php echo Yii::t('app', 'Properties'); ?> </legend> <?php foreach ($availablePropertyGroups as $id => $properties) { ?> <?php $propertyGroup = \app\models\PropertyGroup::findById($id); ?> <fieldset class="property-group"> <legend><?php echo Html::encode($propertyGroup->name); ?> </legend> <?php foreach ($properties as $key => $propertyValue) { echo '<div class="well well-sm well-light"><b>' . \app\models\Property::findById($propertyValue->property_id)->name . ' (<small>' . $key . '</small>)' . '</b>'; $prefix = 'fields[property][' . $propertyValue->property_id . ']['; echo $form->field($model, $prefix . 'enabled]')->checkbox(['label' => Yii::t('app', 'Process')]); $property = \app\models\Property::findById($propertyValue->property_id); if ($property->has_static_values) { echo $form->field($model, $prefix . 'processValuesAs]')->dropDownList(['text' => Yii::t('app', 'Text representation'), 'id' => 'id ' . Yii::t('app', '(static value record id)'), 'value' => Yii::t('app', 'Value representation')])->label(Yii::t('app', 'Process values as:'));