我有: 员工实体:
<?php
namespace PersonnelBundle\Entity\Employee;
use;
//
//
class Employee extends BaseEntity
{
//Some fields
/**
* @ORM\OneToMany(targetEntity="EmployeeMedicalService", mappedBy="employee")
*/
private $employeeMedicalServices;
// getters and setters
}
和 EmployeeMedicalServices实体:
<?php
namespace PersonnelBundle\Entity\Employee;
use
//
//
class EmployeeMedicalService extends BaseEntity
// some fields
/**
* @ORM\ManyToOne(targetEntity="PersonnelBundle\Entity\Employee\Employee" ,inversedBy="employeeMedicalServices")
* @ORM\JoinColumn(name="employee_id",referencedColumnName="id")
*/
private $employee;
//getters setters
}
根据sonata admin tutorial on child Admins
,我正在使用带有此配置的sonata admin捆绑包我的admin.yml:
Services:
{# some services #}
sonata.admin.employee:
class: PersonnelBundle\Admin\Employee\EmployeeAdmin
tags:
- { name: sonata.admin, manager_type: orm, label: "personnel.employee.form.title"}
arguments:
- ~
- PersonnelBundle\Entity\Employee\Employee
- ~
calls:
- [ setTranslationDomain, [messages]]
- [ addChild, ['@sonata.admin.employee_medical_service']]
sonata.admin.employee_medical_service:
class: PersonnelBundle\Admin\Employee\EmployeeMedicalServiceAdmin
tags:
- { name: sonata.admin, manager_type: orm, label: "personnel.employee.medical_service.form.title"}
arguments:
- ~
- PersonnelBundle\Entity\Employee\EmployeeMedicalService
- ~
calls:
- [ setTranslationDomain, [messages]]
我已将此添加到我的子管理类EmployeeMedicalServiceAdmin:
public function getParentAssociationMapping()
{
return 'employee';
}
但它不起作用,我被困在这里,真的需要这个工作