Guest User

Untitled

a guest
Apr 20th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.01 KB | None | 0 0
  1. Customer table:
  2. id INT
  3. name VARCHAR(32)
  4. title_id TINYINT [FK]
  5.  
  6. Title table:
  7. id INT
  8. code VARCHAR(8)
  9. name VARCHAR(24)
  10.  
  11. /**
  12. * Supplier
  13. *
  14. * @ORMTable(name="supplier", indexes={@ORMIndex(name="title_id", columns={"title_id"})})
  15. * @ORMEntity
  16. */
  17. class Supplier
  18. {
  19. /**
  20. * @var int
  21. *
  22. * @ORMColumn(name="id", type="int", nullable=false, options={"unsigned"=true})
  23. * @ORMId
  24. * @ORMGeneratedValue(strategy="IDENTITY")
  25. */
  26. private $id;
  27.  
  28. /**
  29. * @var string
  30. *
  31. * @ORMColumn(name="name", type="string", length=48, nullable=false)
  32. */
  33. private $name;
  34.  
  35. /**
  36. * @var Title
  37. *
  38. * @ORMManyToOne(targetEntity="Title")
  39. * @ORMJoinColumns({
  40. * @ORMJoinColumn(name="title_id", referencedColumnName="id")
  41. * })
  42. */
  43. private $title;
  44.  
  45.  
  46. public function getId(): ?int
  47. {
  48. return $this->id;
  49. }
  50.  
  51. public function getName(): ?string
  52. {
  53. return $this->name;
  54. }
  55.  
  56. public function setName(string $name): self
  57. {
  58. $this->name = $name;
  59.  
  60. return $this;
  61. }
  62.  
  63. public function getTitle(): ?Title
  64. {
  65. return $this->title;
  66. }
  67.  
  68. public function setTitle(?Title $title): self
  69. {
  70. $this->title = $title;
  71.  
  72. return $this;
  73. }
  74.  
  75. public function __toString()
  76. {
  77. return $this->name;
  78. }
  79. }
  80.  
  81. /**
  82. * Title
  83. *
  84. * @ORMTable(name="title")
  85. * @ORMEntity
  86. */
  87. class Title
  88. {
  89. /**
  90. * @var bool
  91. *
  92. * @ORMColumn(name="id", type="boolean", nullable=false)
  93. * @ORMId
  94. * @ORMGeneratedValue(strategy="IDENTITY")
  95. */
  96. private $id;
  97.  
  98. /**
  99. * @var string
  100. *
  101. * @ORMColumn(name="code", type="string", length=8, nullable=false)
  102. */
  103. private $code;
  104.  
  105. /**
  106. * @var string
  107. *
  108. * @ORMColumn(name="name", type="string", length=24, nullable=false)
  109. */
  110. private $name;
  111.  
  112. public function getId(): ?bool
  113. {
  114. return $this->id;
  115. }
  116.  
  117. public function getCode(): ?string
  118. {
  119. return $this->code;
  120. }
  121.  
  122. public function setCode(string $code): self
  123. {
  124. $this->code = $code;
  125.  
  126. return $this;
  127. }
  128.  
  129. public function getName(): ?string
  130. {
  131. return $this->name;
  132. }
  133.  
  134. public function setName(string $name): self
  135. {
  136. $this->name = $name;
  137.  
  138. return $this;
  139. }
  140.  
  141. public function __toString()
  142. {
  143. return $this->name;
  144. }
  145. }
  146.  
  147. class SupplierType extends AbstractType
  148. {
  149. public function buildForm(FormBuilderInterface $builder, array $options)
  150. {
  151. $builder
  152. ->add('name')
  153. ->add('title')
  154. ;
  155. }
  156.  
  157. public function configureOptions(OptionsResolver $resolver)
  158. {
  159. $resolver->setDefaults([
  160. 'data_class' => Supplier::class,
  161. ]);
  162. }
  163. }
  164.  
  165. <select id="supplier_title" name="supplier[title]" class="form-control">
  166. <option value=""></option>
  167. <option value="1" selected="selected">TOKO</option>
  168. <option value="1" selected="selected">TOKO</option>
  169. <option value="1" selected="selected">TOKO</option>
  170. </select>
Add Comment
Please, Sign In to add comment