我在 symfony2 中的验证表单有问题。
我有一个带有实体的表格。进入文件'validation.yml'我使用了CALLBACK:它调用文件'Entity.php'中的方法'isValidForm'内容
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 ();
}
有可能的?我该怎么做?