问题描述
除了我之前的问题 附加 zend 过滤器和模型/学说实体的验证链我尝试过 Spiffy 框架,但我得到了这样的异常堆栈:异常没有为标题"指定表单元素,并且没有从Spiffy"自动确定\Zend\Form".在我的实体中,我有这个:
In addtion to my previous question Attache zend filters and validation chains to models/doctrine entities I have given a try to Spiffy framework, but I got stack with this exception like this: Exception No form element was specified for "title" and one not be determined automatically from "Spiffy\Zend\Form".In my entity I have this:
<?php
namespace Entities;
use Doctrine\ORM\Mapping as ORM;
use Spiffy\Doctrine\AbstractEntity as Entity;
use Spiffy\Doctrine\Annotations\Filters as Filter;
use Spiffy\Doctrine\Annotations\Validators as Assert;
/** @ORM\Entity(repositoryClass="Repositories\PostRepository") */
class Post extends Entity {
public function __construct()
{
$this->created = new \DateTime("now");
$this->comments = new \Doctrine\Common\Collections\ArrayCollection();
}
public function __get($property)
{
return $this->$property;
}
public function __set($name, $value)
{
$this->$name = $value;
return $this->$name;
}
/**
* @ORM\Id @ORM\Column(type="integer") @ORM\GeneratedValue
*/
private $id;
/**
* @var string $title
* @Filter\Alnum
* @Assert\StringLength(5)
* @ORM\Column(type="string",length=255)
*/
private $title;
/**
* @ORM\Column(type="text")
*/
private $body;
/**
* @ORM\Column(type="datetime")
*/
private $created;
/**
* @ORM\OneToMany(targetEntity="Comment", mappedBy="post", fetch="LAZY")
*/
private $comments;
}
我的表格是这样的:
<?php
use \Spiffy\Zend\Form as Form;
class Application_Form_Post extends Form
{
public function init()
{
//var_dump($this->getEntity()); //returns null
// die;
$this->add('title');
$this->add('body');
$this->addElement('submit', 'submit', array(
));
}
}
所以我把自己挡在了这里.感谢您的帮助.
So I am block myself here. Thank you for your help.
推荐答案
在我的 application.ini 中,我注释掉了以下几行:
In my application.ini, I comented out this lines:
pluginPaths.Bisna\Application\Resource\ = "Bisna/Application/Resource"
和
autoloaderNamespaces[] = Bisna
但我仍然有异常:
Uncaught exception 'ReflectionException' with message 'Class Doctrine\ORM\Mapping\Driver\AnnotationDriver does not exist' in C:\Spiffy\lib\Spiffy\Doctrine\Container.php on line 359
我不清楚的是,在 bisna 资源中我有这样的东西:
What is not clear for me, is that in the bisna resource I had something like this:
\Zend_Registry::set('doctrine', $container);
在我有这样的漂亮资源中:
and in the spiffy resource I had like this:
`Zend_Registry::set('Spiffy_Doctrine', $container);`
但是在我的 Boostrap.php 中,我有这两个:
But in my Boostrap.php, I had this two:
$this->bootstrap('doctrine');
$container = $this->getResource('doctrine');
我原以为教义和 Spiffy_Doctrine 之间存在差异,但事实并非如此.还有一些对我来说是无法理解的.我像这样修改 Spiffy 容器中的一些行:
I was expected to be a diffrence between doctrine and Spiffy_Doctrine, but is not. And something else that is for me, not understandable. I modify some line in Spiffy container like this:
try{
$reflClass = new ReflectionClass($driverClass);
}catch (LogicException $Exception) {
die('Not gonna make it in here...');
}
catch(ReflectionException $Exception)
{
die('Your class does not exist! ' );
}
但我没有捕获异常,而是得到了这个:
but instead of cacthing the exception, I got this:
`Uncaught exception 'ReflectionException'`
Ps:很抱歉从linekdin 复制了教义组的内容,但这些是我的回答.现在我正在调试我的应用程序,也许我会弄清楚我缺少什么,但是任何帮助都会很棒.谢谢.
Ps: Sorry for the duplication of content from the doctrine group from linekdin, but these are my answers. Rigth now I debug my application, maybe I will figure out what I'm missing, but any help will be great. Thank you.
这篇关于例外 没有为“title"指定表单元素一个不是从“Spiffy\Zend\Form"中自动确定的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!