FOSUserBundle
FOSUserBundle copied to clipboard
"This value should not be blank. " when I enter an existing username
Hi,
I'm trying to create a form where you can select a user (this example is a new article where the user can write (text) a username). When I write an existing username I have the error: "This value should not be blank.", when it's a not existing username I get: This value is not valid.
// ArticleType.php ->add('author', 'fos_user_username')
OR (I've the same problem with a custom model transformer) ->add( $builder->create('author', 'text')->addModelTransformer($transformer) );
// Article entity with a linked author
/**
* @assert\Type(type="Acme\UserBundle\Entity\User", groups={"default", "registration", "profile"})
* @ORM\OneToOne(targetEntity="Acme\UserBundle\Entity\User")
* @ORM\JoinColumn(name="user_id", referencedColumnName="id")
*/
private $author;
Thanks!
This value should not be blank. for an existing username ? This looks weird.
which Symfony version are you using ? and which validation groups are you using in your form ?
Thanks for your fast answer! Yes, when I write an existing username I get this error. When it doesn't exist, I also got an error.
I'm using Symfony2.1 and the latest FOS User Bundle.
The form for creating an article contains no validation.
I've the same error when I select an existing user in a select box:
->add('author')
When I remove the "if ($form->isValid()) {" statement in the controller, everything works fine and the username is correctly "translated" to an ID and saved in the database. Strange...
I am having the same issue
I am having the same issue