public function __ModelTabsConstruct($rowParams = [], $value = "", $item = []) { $model_tabs = new \app\modelsActiveRecords\Tabs(); $getTabs = $model_tabs->GetItems($value); $tabs = ArrayHelper::toArray($getTabs); $params = yii::$app->request->bodyParams; if (!empty($params["tabs"])) { $model_tabs->Add($value, $params["tabs"]); } $tag = Html::beginTag('table', ['style' => 'width:100%']); $tag .= Html::a('Добавить поле', 'javascript:void(0)', ['onclick' => 'addTabRow(this)']); $tag .= Html::beginTag('tr'); $tag .= Html::tag('th', 'Имя вкладки'); $tag .= Html::tag('th', 'Название вкладки'); $tag .= Html::tag('th', 'Класс'); $tag .= Html::tag('th', 'Индекс сортировки'); $tag .= Html::tag('th', 'Действие'); $tag .= Html::endTag('tr'); if (!empty($tabs)) { foreach ($tabs as $index => $value) { $tag .= Html::beginTag('tr'); $tag .= Html::tag('td', Html::textInput("tabs[{$index}][name]", $value["name"])); $tag .= Html::tag('td', Html::textInput("tabs[{$index}][title]", $value["title"])); $tag .= Html::tag('td', Html::textInput("tabs[{$index}][class]", $value["class"])); $tag .= Html::tag('td', Html::textInput("tabs[{$index}][index]", $value["index"], ["type" => "number"])); $tag .= Html::tag('td', Html::a('Удалить', 'javascript:void(0)', ['onclick' => 'removeRow(this)'])); $tag .= Html::endTag('tr'); } } $tag .= Html::endTag('table'); return $tag; }
/** * Формирование Вкладок * @param unknown $model */ protected function buildTabs($model) { $module_model = new DinamicModel(); $module_model->setTableName('module'); $info_module = $module_model->find()->select(['model'])->where(['name' => $this->ExecModule()])->one(); $tabs_model = new app\modelsActiveRecords\Tabs(); $model_id = $model == 0 ? ArrayHelper::toArray($info_module)["model"] : $model; return $tabs_model->GetItems($model_id); }
/** * Свойства модели * @return string */ public function actionProperty() { $id = yii::$app->request->get('id') ? (int) yii::$app->request->get('id') : 0; if ($id) { $m_tabs = new Tabs(); $m_tables = new Tables(); $m_rows = new Rows(); $item = $this->GetModel()->GetItem($id); $data['rows'] = $m_rows->GetRows($id); $data['tabs'] = $m_tabs->GetItems($id); $table_columns = $m_tables->GetTableForModelId($id); $data['column'] = $this->GetModel()->GetColumnFromTable($table_columns); $this->titlePage = "Модель " . $item["name"]; $this->headerPage = "Свойство модели / " . $item["name"]; if (isset($_POST["saveAction"])) { if (isset(yii::$app->request->bodyParams["row"])) { $fields = yii::$app->request->bodyParams["row"]; foreach ($fields as $id_section => $value) { $m_rows->Add($id_section, $value, $id); } } $this->redirect(Url::to(["/models/catalog/property", "id" => $id])); } return $this->render('property', ["data" => $data, "id" => $id]); } }