0
我在symfony2驗證表單有問題。驗證Symfony2與查詢到數據庫
我有一個形式與實體。到文件 'validation.yml' 我使用的回調:它在調用文件的方法 'isValidForm' 內容 'Entity.php'
ALM\CreateReleaseBundle\Entity\createReleaseEntity:
constraints:
- Callback:
methods: [isFormValid]
這是我的文件 'Entity.php'
<?php
namespace ALM\CreateReleaseBundle\Entity;
use Symfony\Component\Validator\ExecutionContext;
class createReleaseEntity {
protected $area;
protected $relName;
public function getArea() {
return $this->area;
}
public function setArea($area) {
$this->area = $area;
}
public function getRelName() {
return $this->relName;
}
public function setRelName($relName) {
$this->relName = $relName;
}
public function isFormValid(ExecutionContext $context) {
// Validate Form
}
}
現在在'isFormValid'中,我想插入一個轉發到放置在另一個控制器中的getRelease函數。
public function getReleaseAction (Request $request) {
$area = $request->get('area');
$relName = $request->get('relName');
$ret = $this->getRelease($area,$relName);
$session = $this->get('request')->getSession();
$session->set("releaseObj", $ret);
return new Response();
}
有可能嗎?我如何做到這一點?