The form has been generated successfully.
You may add the following code in an appropriate controller class to invoke the view:
EOD;
$code="render($this->templatePath.'/action.php');
return $output.highlight_string($code,true);
}
public function validateModel($attribute,$params)
{
if($this->hasErrors('model'))
return;
$class=@Yii::import($this->model,true);
if(!is_string($class) || !$this->classExists($class))
$this->addError('model', "Class '{$this->model}' does not exist or has syntax error.");
elseif(!is_subclass_of($class,'CModel'))
$this->addError('model', "'{$this->model}' must extend from CModel.");
else
$this->_modelClass=$class;
}
public function validateViewPath($attribute,$params)
{
if($this->hasErrors('viewPath'))
return;
if(Yii::getPathOfAlias($this->viewPath)===false)
$this->addError('viewPath','View Path must be a valid path alias.');
}
public function prepare()
{
$templatePath=$this->templatePath;
$this->files[]=new CCodeFile(
Yii::getPathOfAlias($this->viewPath).'/'.$this->viewName.'.php',
$this->render($templatePath.'/form.php')
);
}
public function getModelClass()
{
return $this->_modelClass;
}
public function getModelAttributes()
{
$model=new $this->_modelClass($this->scenario);
return $model->getSafeAttributeNames();
}
}