1
我在Zend框架中实现表单时遇到了问题1.我在application/forms/CustomForm.php中添加了表单。它看起来像这样。Zend表格自动加载
class CustomForm extends Zend_Form
{
public function init()
{
$this->setMethod('post');
$id = $this->createElement('hidden','id');
$firstname = $this->createElement('text','firstname');
$firstname->setLabel('First Name:')
->setAttrib('size',50);
$lastname = $this->createElement('text','lastname');
$lastname->setLabel('Last Name:')
->setAttrib('size',50);
$username = $this->createElement('text','username');
$username->setLabel('Username:')
->setAttrib('size',50);
$email = $this->createElement('text','email');
$email->setLabel('Email:')
->setAttrib('size',50);
$password = $this->createElement('password','password');
$password->setLabel('Password:')
->setAttrib('size',50);
$password2 = $this->createElement('password','password2');
$password2->setLabel('Confirm Password::')
->setAttrib('size',50);
$register = $this->createElement('submit','register');
$register->setLabel("Register")
->setIgnore(true);
$this->addElements(array(
$firstname,
$lastname,
$username,
$email,
$password,
$password2,
$id,
$register
));
}
}
,包括在index.php文件看起来像这样
set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../library'),
realpath(APPLICATION_PATH . '/../application'),
realpath(APPLICATION_PATH . '/../application/forms'),
)));
但是,当我打电话$form = new CustomForm();
,在usercontroller.php,我得到这个“致命错误路径:类‘CustomForm’未找到在250行的/var/www/demoapp/application/controllers/UserController.php“。可能是什么问题?
'的var_dump(真实路径(APPLICATION_PATH '/../应用/表格'));'并仔细检查,这是你所期望的。 – mkaatman
雅路径是正确的,我得到这个字符串(37)“/ var/www/demoapp/application/forms” – Ninju
哦,等等,我看到发生了什么。您正试图自动加载它。 set_include_path设置可用的路径,但您仍然需要包含/需要这些文件。你可能想要做的是设置自动加载。 http://framework.zend.com/manual/1.12/en/zend.loader.autoloader.html – mkaatman