editorClasses = $editorClasses; if(is_object($src)) { if($src instanceof iModel) $this->model = &$src; else throw new \InvalidArgumentException(get_class($src) . ' does not implement the iModel interface'); } elseif(is_string($src)) { if(!class_exists($src)) throw new \InvalidArgumentException($src . ' is a unknown class'); $this->model = new $src(); if(!($this->model instanceof iModel)) throw new \InvalidArgumentException(get_class($src) . ' does not implement the iModel interface'); } elseif ($src === false) { return; } else throw new \InvalidArgumentException('Class needs to be an object or a classname'); $fields = call_user_func(array(get_class($this->model),'fieldInfo')); foreach($fields as $name=>$info) { $this->editors[$name] = $this->generateEditorFor($info); $this->editors[$name]->setName($name); $this->editors[$name]->loadFromObject($this->model); } } public function replaceEditorInfo($name, $newInfo) { $this->editors[$name] = $this->generateEditorFor($newInfo); $this->editors[$name]->setName($name); $this->editors[$name]->loadFromObject($this->model); } public function setRequiredFields(array $required) { $this->required = $required; } public function setMethod($method) { $this->method = strtoupper((string) $method); } public function setEncoding($encoding) { $this->encoding = (string) $encoding; } public function setEditorParams($editor, array $param) { $this->editorParams[$editor] = $param; } public function getEditorParams($editor) { return $this->editorParams[$editor]; } public function setTargetLink($link) { if($this->started) throw new IllegalStateException('form generation has been started'); $this->targetLink = $link; } public function setTargetParams($params) { if($this->started) throw new IllegalStateException('form generation has been started'); $this->targetParams = $params; } public function genStart() { $this->started = true; $st = '
'; return $st; } }