There are 2 entity many-to-many relations with join table in symfony 2. First one is certificate, second one is mayag and join table is certificate_mayag. Certificate has many mayag with isAvailable, startDate, endDate fields. A mayag has many certificate.
I want to render this relation by checkbox form. The form consists of certificate info and mayag list with checkbox and startdate, enddate and isavailable fields. How to do this solution and which one is the best way to develop?
<?php
/**
* Created by PhpStorm.
* User: Mendbayar
* Date: 12/8/13
* Time: 1:00 PM
*/
namespace Mnd\SrdBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="Mnd\SrdBundle\Repository\CertifyRepository")
* @ORM\Table(name="Certify")
*/
class Certify {
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @ORM\Column(type="string", unique=true, length=50)
*/
protected $certificate_number;
/**
* @ORM\ManyToOne(targetEntity="CertificateOwner", inversedBy="certificates")
* @ORM\JoinColumn(name="owner_id", referencedColumnName="id")
*/
protected $owner;
/**
* @ORM\ManyToOne(targetEntity="Document", inversedBy="certificates")
* @ORM\JoinColumn(name="document_id", referencedColumnName="id")
*/
protected $document;
/**
* @ORM\ManyToOne(targetEntity="Action", inversedBy="certificates")
* @ORM\JoinColumn(name="action_id", referencedColumnName="id")
*/
protected $action;
/**
* @ORM\OneToMany(targetEntity="Extension", mappedBy="certify")
*/
protected $extensions;
/**
* @ORM\OneToMany(targetEntity="CertifyMayag", mappedBy="certify")
*/
protected $mayags;
}
<?php
/**
* Created by PhpStorm.
* User: Mendbayar
* Date: 12/22/13
* Time: 1:41 PM
*/
namespace Mnd\SrdBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="Mnd\SrdBundle\Repository\CertifyMayagRepository")
* @ORM\Table(name="certify_mayag")
*/
class CertifyMayag {
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\ManyToOne(targetEntity="Certify", inversedBy="certifyMayags")
* @ORM\JoinColumn(name="certifyId", referencedColumnName="id")
*/
protected $certify;
/**
* @ORM\ManyToOne(targetEntity="Mayag", inversedBy="MayagCertifies")
* @ORM\JoinColumn(name="mayagId", referencedColumnName="id")
*/
protected $mayag;
/**
* @ORM\Column(type="boolean")
*/
protected $isAvailable;
/**
* @ORM\Column(type="datetime")
*/
protected $startDate;
/**
* @ORM\Column(type="datetime")
*/
protected $endDate;
}
<?php
/**
* Created by PhpStorm.
* User: Mendbayar
* Date: 12/22/13
* Time: 1:38 PM
*/
namespace Mnd\SrdBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="Mnd\SrdBundle\Repository\MayagRepository")
* @ORM\Table(name="Mayag")
*/
class Mayag {
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\Column(type="string")
* */
protected $name;
/**
* @ORM\OneToMany(targetEntity="CertifyMayag", mappedBy="mayag")
*/
protected $certifies;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
protected $isAvailable;
/**
* @ORM\Column(type="datetime")
*/
protected $startDate;
/**
* @ORM\Column(type="datetime")
*/
protected $endDate;
/**
* @ORM\Column(type="text")
* */
protected $description;
}
3 entities have automatic getter setter.