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