Answer the question
In order to leave comments, you need to log in
How to properly use EntityType in Symfony4?
I have two Entiny: "Member" and "DepartmentPo".
"Member" contains a poId field that points to "DepartmentPo".
namespace App\Entity;
class Member
{
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $poId;
$builder
->add('poId', EntityType::class, array(
'class' => DepartmentPo::class,
'choice_label' => 'title',
'placeholder' => '..не выбрано..',
'empty_data' => null,
'required' => false,
'label' => 'Первичное отделение',
))
Member {#7045 ▼
-id: null
-poId: DepartmentPo {#9884 ▼
-id: 23000009
-moId: 23000
-title: "Абинское №9"
-titleMo: "23000"
}
}
Notice: Object of class App\Entity\DepartmentPo could not be converted to int
'INSERT INTO member (ro_id, mo_id, po_id)
VALUES (?, ?, ?, ?)'
with params [23, 23000, {}, 6]:
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question