public function load($data, $formName = null) { if (parent::load($data, $formName)) { $this->links = []; for ($i = 0; $i < count($data['title']); $i++) { $this->links[$i] = ['title' => $data['title'][$i], 'url' => $data['url'][$i]]; } return true; } return false; }
public function actionCreate($id) { $model = new DynamicBlockModel(); $model->widgetId = $id; if (Yii::$app->request->isPost) { $model->load(Yii::$app->request->post()); if ($model->validate()) { $model->createBlock(); return $this->redirect(['config', 'id' => $model->blockId]); } } return $this->render('create', ['model' => $model]); }
public function load($data, $formName = null) { if (parent::load($data, $formName)) { $this->filterCategories = []; foreach ($data as $p => $v) { if (strpos($p, '_fc') === 0) { $id = str_replace('_fc', '', $p); $this->filterCategories[$id] = $v; } } return true; } return false; }
public function load($data, $formName = null) { if (parent::load($data, $formName)) { $this->items = []; for ($i = 0; $i < count($data['title']); $i++) { if (intval($data['id'][$i]) != 0) { $id = intval($data['id'][$i]); $this->items[$id] = ['label' => $data['title'][$i], 'url' => $data['url'][$i]]; } elseif (intval($data['parent'][$i]) != 0) { $id = intval($data['parent'][$i]); $this->items[$id]['items'][] = ['label' => $data['title'][$i], 'url' => $data['url'][$i]]; // $this->items[$id]['url'] = '#'; } } Yii::trace(VarDumper::dumpAsString($this->items)); Yii::trace(VarDumper::dumpAsString($data)); return true; } return false; }