The solution is validation groups.
Tanks
On 10 maio, 08:53, elcabong elcabong@gmail.com wrote:
Controller:
namespace MCP\AdminBundle\Controller;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use MCP\AdminBundle\Form\ParceiroType;
use
Ah, that makes sense.
So the validation framework was not taking into account that the Cidade was
already persisted, and was assuming it was a duplicate. So now you're going
to use validation groups to exclude the Cidade from the validation?
On Wed, May 11, 2011 at 7:10 AM, elcabong
Yes
I dont need validation Cidade. It is only object associated with Parceiro.
When I create new Cidade, I use another validation group.
Validation.xml:
?xml version=1.0 encoding=UTF-8?
constraint-mapping xmlns=http://symfony.com/schema/dic/constraint-mapping;
Controller:
namespace MCP\AdminBundle\Controller;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use MCP\AdminBundle\Form\ParceiroType;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
class ParceiroController
Entities:
class Cidade
{
/**
* @var string $nome
*/
private $nome;
/**
* @var boolean $ativo
*/
private $ativo;
/**
* @var bigint $id
*/
private $id;
/**
* Set nome
*
* @param string $nome
*/
public function
I don't see any info on your class annotations for what properties are
required to be unique.
On Mon, May 9, 2011 at 7:27 AM, elcabong elcabong@gmail.com wrote:
Entities:
class Cidade
{
/**
* @var string $nome
*/
private $nome;
/**
* @var boolean $ativo
This validation config:
?xml version=1.0 encoding=UTF-8?
constraint-mapping xmlns=http://symfony.com/schema/dic/constraint-
mapping
xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance;
xsi:schemaLocation=http://symfony.com/schema/dic/constraint-mapping
You said that you weren't creating a new Cidade, so that means that
the Parceiro
was using an existing Cidade, correct?
On Mon, May 9, 2011 at 7:44 AM, elcabong elcabong@gmail.com wrote:
This validation config:
?xml version=1.0 encoding=UTF-8?
constraint-mapping
Yes
What can I try to do for this not to happen??
Tanks
On May 9, 9:51 am, Donald Tyler chekot...@gmail.com wrote:
You said that you weren't creating a new Cidade, so that means that
the Parceiro
was using an existing Cidade, correct?
On Mon, May 9, 2011 at 7:44 AM, elcabong
The only thing I can think is happening is that the Cidade is becoming
detached from the Entity Manager somehow, and when you persist the new
Parceiro, it's actually trying to persist the Cidade again.
Can you post the full code for the Controller action that's throwing the
Unique Constraint
10 matches
Mail list logo