public function getSelected() { $model = $this->getForm()->getInstance(); $value = $this->getValue(); if (!$value && $model->pk) { $data = CustomRelation::objects()->filter(['owner_pk' => $model->pk, 'owner_class' => $model->className(), 'field' => $this->field, 'name' => $this->getName()])->order(['position'])->valuesList(['related_class', 'related_pk']); $value = []; foreach ($data as $item) { $value[] = $item['related_class'] . ':' . $item['related_pk']; } } elseif ($value) { $value = Json::decode($value); } return $value ? $value : []; }
public function toJson() { return Json::encode($this->_data); }
protected function readMigration($filename) { $json = file_get_contents($filename); return Json::decode($json); }
public function toJson() { return Json::encode($this->toArray()); }
public function redirectNext($data, $form) { if (Mindy::app()->request->getIsAjax()) { echo Json::encode(['status' => 'success', 'content' => $this->renderTemplate($this->successTemplate, ['data' => $data, 'form' => $form])]); Mindy::app()->end(); } else { list($route, $params) = $this->getNextRoute($data, $form); if ($route && $params) { $this->redirect($route, $params); } } }
public function getDbPrepValue() { return is_string($this->value) ? $this->value : Json::encode($this->value); }