ich meine Benutzereinheit eingerichtet haben, und E-Mail (varchar) als Primärschlüssel (id) ich habe ein Anmeldeformular und alle adaequatLehre-Symfony3: varchar Primärschlüssel nicht zur Datenbank hinzugefügt
das Problem ist, wenn ich die Form in der Datenbank einreichen, ist die E-Mail-Spalte leer
Benutzer Einheit:
/**
* Utilisateur
*
* @ORM\Table(name="utilisateur", indexes={@ORM\Index(name="FK_utilisateur_niveau", columns={"niveau"})})
* @ORM\Entity
*/
class Utilisateur
{
/**
* @var string
*
* @ORM\Column(name="pseudo", type="string", length=150, nullable=false)
*/
private $pseudo;
/**
* @var string
*
* @ORM\Column(name="password", type="string", length=250, nullable=false)
*/
private $password;
/**
* @var string
*
* @ORM\Column(name="email", type="string", length=150, nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="NONE")
*/
private $email;
/**
* @var \EncheresBundle\Entity\Role
*
* @ORM\ManyToOne(targetEntity="EncheresBundle\Entity\Role")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="niveau", referencedColumnName="niveau")
* })
*/
private $niveau;
/**
* Set pseudo
*
* @param string $pseudo
*
* @return Utilisateur
*/
public function setPseudo($pseudo)
{
$this->pseudo = $pseudo;
return $this;
}
/**
* Get pseudo
*
* @return string
*/
public function getPseudo()
{
return $this->pseudo;
}
/**
* Set password
*
* @param string $password
*
* @return Utilisateur
*/
public function setPassword($password)
{
$this->password = $password;
return $this;
}
/**
* Get password
*
* @return string
*/
public function getPassword()
{
return $this->password;
}
/**
* Get email
*
* @return string
*/
public function getEmail()
{
return $this->email;
}
/**
* Set email
*
* @param string $email
*
* @return Utilisateur
*/
public function setEmail($email)
{
$this->email = $email;
return $this;
}
/**
* Set niveau
*
* @param \EncheresBundle\Entity\Role $niveau
*
* @return Utilisateur
*/
public function setNiveau(\EncheresBundle\Entity\Role $niveau = null)
{
$this->niveau = $niveau;
return $this;
}
/**
* Get niveau
*
* @return \EncheresBundle\Entity\Role
*/
public function getNiveau()
{
return $this->niveau;
}
}
hier ist der Einsatzblock:
if ($form->isSubmitted() && $form->isValid()) {
$obj->setEmail($form['email']->getData());
$obj->setPseudo($form['pseudo']->getData());
$obj->setPassword($form['password']->getData());
$obj->setNiveau($form['niveau']->getData());
$em = $this->getDoctrine()->getManager();
$em->persist($obj);
$em->flush();
$this->addFlash('notice', 'Inscription effectuee !');
return $this->redirectToRoute('login');
}
wo ging ich schief?
Können Sie Ihren vollständigen Entity-Code anzeigen? Alles scheint in Ordnung zu sein von dem, was du bisher gepostet hast. –
ok Bewertung Ich bearbeite Frage – Souf
Warum weisen Sie Ihrer Entität Formularwerte zu? '$ obj-> setEmail ($ form [ 'email'] -> getData());' , wenn Sie zuvor Form und Modell binded, sollten sie automatisch zugewiesen werden: '$ form = $ this-> createForm (TaskType :: class, $ task); $ form-> handleRequest ($ request); ' http://symfony.com/doc/current/forms.html#handling-form-submissions – CountZero