I need help. I have 3 entities: Customer
OneToMany Preference
ManyToOne Typology
.
Customers must be able to set their own user 'Preferences' via a 'Typologies' checkbox. Preferences can be changed when the user wants it.
The form should show preferences in the db as checked.
I'm new of Symfony and I don't know how to do this. How do I build the form? How can I handle data in db?
Here the entities:
Preference.php
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Preference
*
* @ORM\Table(name="preference", indexes={@ORM\Index(name="fk_preference_typology1_idx", columns={"typology_id"}), @ORM\Index(name="fk_preference_customer1_idx", columns={"customer_id"})})
* @ORM\Entity
*/
class Preference
{
/**
*
* @ORM\Column(name="id", type="integer", length=45)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var \DateTime
*
* @ORM\Column(name="date", type="datetime", nullable=true)
*/
private $date;
/**
* @var \AppBundle\Entity\Customer
*
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\Customer")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="customer_id", referencedColumnName="id")
* })
*/
private $customer;
/**
* @var \AppBundle\Entity\Typology
*
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\Typology")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="typology_id", referencedColumnName="id")
* })
*/
private $typology;
/**
* @return Customer
*/
public function getCustomer()
{
return $this->customer;
}
/**
* @param Customer $customer
*/
public function setCustomer($customer)
{
$this->customer = $customer;
}
/**
* @return Typology
*/
public function getTypology()
{
return $this->typology;
}
/**
* @param Typology $typology
*/
public function setTypology($typology)
{
$this->typology = $typology;
}
}
Typology.php
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Typology
*
* @ORM\Table(name="typology")
* @ORM\Entity
*/
class Typology
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="value", type="string", length=100, nullable=false)
*/
private $value;
}
Thanks
Aucun commentaire:
Enregistrer un commentaire