UPDATE形式不绑定的所有数据
当我使用:
public function setUrl_key($value) { $this->url_key = $value; }
public function getUrl_key() { return $this->url_key; }
相反的:
public function setUrlKey($value) { $this->url_key = $value; }
public function getUrlKey() { return $this->url_key; }
工作正常。为什么?
使用ZF2与学说2.在我的形式的编辑操作仅领域title
和email
显示在他们的文本框中。其他文本框是空的,就好像数据库中没有值一样。但是还有。
但是,如果我把url_key
例如email
setter/getter像下面它的工作。
public function setEmail($value) { $this->url_key = $value; }
public function getEmail() { return $this->url_key; }
通过电子邮件getter工作...我想我的约束力或教条2水合作用有什么不对吗?
下面是我的一些代码:
控制器
$link = $this->getObjectManager()->getRepository('Schema\Entity\Link')->find($this->params('id'));
$form = new AdminLinkForm($this->getObjectManager());
$form->setHydrator(new DoctrineEntity($this->getObjectManager(),'Schema\Entity\Link'));
$form->bind($link);
$request = $this->getRequest();
if ($request->isPost()) {
实体(setter方法&干将)
.....
/** @ORM\Column(type="string", name="title", length=255, nullable=false) */
protected $title;
/** @ORM\Column(type="string", length=255, nullable=false) */
protected $short_description;
/** @ORM\Column(type="string", length=255, nullable=true) */
protected $image;
/** @ORM\Column(type="text", nullable=true) */
protected $sample_title;
/** @ORM\Column(type="text", nullable=true) */
protected $sample_description;
/** @ORM\Column(type="text", nullable=true) */
protected $sample_keys;
/** @ORM\Column(type="string", name="webpage_url", length=255, nullable=false) */
protected $webpage_url;
/** @ORM\Column(type="string", length=255, nullable=true) */
protected $email;
......
public function setId($value) { $this->link_id = (int)$value; }
public function getId() { return $this->link_id; }
public function setTitle($value) { $this->title = $value; }
public function getTitle() { return $this->title; }
public function setShortDesc($value) { $this->short_description = $value; }
public function getShortDesc() { return $this->short_description; }
public function setUrlKey($value) { $this->url_key = $value; }
public function getUrlKey() { return $this->url_key; }
public function setEmail($value) { $this->email = $value; }
public function getEmail() { return $this->email; }
这就是为什么我使用下划线。希望在数据库字段中有下划线,并且不知道(name =“field_name”)注释。谢谢 – Nikitas