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 "SpiffyendForm". In my entity I have this:
<?php
namespace Entities;
use DoctrineORMMapping as ORM;
use SpiffyDoctrineAbstractEntity as Entity;
use SpiffyDoctrineAnnotationsFilters as Filter;
use SpiffyDoctrineAnnotationsValidators as Assert;
/** @ORMEntity(repositoryClass="RepositoriesPostRepository") */
class Post extends Entity {
public function __construct()
{
$this->created = new DateTime("now");
$this->comments = new DoctrineCommonCollectionsArrayCollection();
}
public function __get($property)
{
return $this->$property;
}
public function __set($name, $value)
{
$this->$name = $value;
return $this->$name;
}
/**
* @ORMId @ORMColumn(type="integer") @ORMGeneratedValue
*/
private $id;
/**
* @var string $title
* @FilterAlnum
* @AssertStringLength(5)
* @ORMColumn(type="string",length=255)
*/
private $title;
/**
* @ORMColumn(type="text")
*/
private $body;
/**
* @ORMColumn(type="datetime")
*/
private $created;
/**
* @ORMOneToMany(targetEntity="Comment", mappedBy="post", fetch="LAZY")
*/
private $comments;
}
我的表象是这样:
<?php
use SpiffyendForm 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(
));
}
}
因此,我在这里被困。 感谢您的帮助。