예제 #1
0
 public function render()
 {
     global $redirectedPackage;
     global $packageSchema;
     $name = $this->getName();
     $hidden = new HiddenField($name, $this->getValue());
     $id = $this->getId();
     $hidden->addAttribute("id", $id);
     $ret = $hidden->render();
     if ($this->storedFieldSet === false) {
         $this->addSearchField($this->storedField);
         $this->storedFieldSet = true;
     }
     $object = array("model" => $this->model->package, "format" => "json", "fields" => $this->searchFields, "limit" => 20, "conditions" => "", "and_conditions" => $this->andConditions, 'and_bound_data' => $this->andBoundData, 'redirected_package' => $redirectedPackage, 'package_schema' => $packageSchema);
     $jsonSearchFields = array_reverse($this->searchFields);
     $object = base64_encode(serialize($object));
     $path = Application::$prefix . "/system/api/query?object={$object}";
     $fields = urlencode(json_encode($jsonSearchFields));
     $text = new TextField();
     $text->addAttribute("onkeyup", "fapiUpdateSearchField('{$id}','{$path}','{$fields}',this," . ($this->boldFirst ? "true" : "false") . ",'{$this->onChangeAttribute}')");
     $text->addAttribute("autocomplete", "off");
     foreach ($this->attributes as $attribute) {
         $text->addAttributeObject($attribute);
     }
     if ($this->getValue() != "") {
         $data = $this->model[$this->getValue()];
         for ($i = 2; $i < count($jsonSearchFields); $i++) {
             $val .= $data[0][$jsonSearchFields[$i]] . " ";
         }
         $text->setValue($val);
     }
     $text->setId($id . "_search_entry");
     $ret .= $text->render();
     $ret .= "<div class='fapi-popup' id='{$id}_search_area'></div>";
     return $ret;
 }