Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Customer table:
- id INT
- name VARCHAR(32)
- title_id TINYINT [FK]
- Title table:
- id INT
- code VARCHAR(8)
- name VARCHAR(24)
- /**
- * Supplier
- *
- * @ORMTable(name="supplier", indexes={@ORMIndex(name="title_id", columns={"title_id"})})
- * @ORMEntity
- */
- class Supplier
- {
- /**
- * @var int
- *
- * @ORMColumn(name="id", type="int", nullable=false, options={"unsigned"=true})
- * @ORMId
- * @ORMGeneratedValue(strategy="IDENTITY")
- */
- private $id;
- /**
- * @var string
- *
- * @ORMColumn(name="name", type="string", length=48, nullable=false)
- */
- private $name;
- /**
- * @var Title
- *
- * @ORMManyToOne(targetEntity="Title")
- * @ORMJoinColumns({
- * @ORMJoinColumn(name="title_id", referencedColumnName="id")
- * })
- */
- private $title;
- public function getId(): ?int
- {
- return $this->id;
- }
- public function getName(): ?string
- {
- return $this->name;
- }
- public function setName(string $name): self
- {
- $this->name = $name;
- return $this;
- }
- public function getTitle(): ?Title
- {
- return $this->title;
- }
- public function setTitle(?Title $title): self
- {
- $this->title = $title;
- return $this;
- }
- public function __toString()
- {
- return $this->name;
- }
- }
- /**
- * Title
- *
- * @ORMTable(name="title")
- * @ORMEntity
- */
- class Title
- {
- /**
- * @var bool
- *
- * @ORMColumn(name="id", type="boolean", nullable=false)
- * @ORMId
- * @ORMGeneratedValue(strategy="IDENTITY")
- */
- private $id;
- /**
- * @var string
- *
- * @ORMColumn(name="code", type="string", length=8, nullable=false)
- */
- private $code;
- /**
- * @var string
- *
- * @ORMColumn(name="name", type="string", length=24, nullable=false)
- */
- private $name;
- public function getId(): ?bool
- {
- return $this->id;
- }
- public function getCode(): ?string
- {
- return $this->code;
- }
- public function setCode(string $code): self
- {
- $this->code = $code;
- return $this;
- }
- public function getName(): ?string
- {
- return $this->name;
- }
- public function setName(string $name): self
- {
- $this->name = $name;
- return $this;
- }
- public function __toString()
- {
- return $this->name;
- }
- }
- class SupplierType extends AbstractType
- {
- public function buildForm(FormBuilderInterface $builder, array $options)
- {
- $builder
- ->add('name')
- ->add('title')
- ;
- }
- public function configureOptions(OptionsResolver $resolver)
- {
- $resolver->setDefaults([
- 'data_class' => Supplier::class,
- ]);
- }
- }
- <select id="supplier_title" name="supplier[title]" class="form-control">
- <option value=""></option>
- <option value="1" selected="selected">TOKO</option>
- <option value="1" selected="selected">TOKO</option>
- <option value="1" selected="selected">TOKO</option>
- </select>
Add Comment
Please, Sign In to add comment