현재 각 회사 이름 옆에 확인란이있는 회사 목록이있는 Symfony에서 작동하는 양식이 있습니다. 이렇게하면 각 사용자에게 할당 된 회사를 확인할 수 있습니다. 체크 박스는 현재 accountID를 보여 주지만 엔터티 필드 'name'을 갖는 것도 도움이 될 것입니다. 두 개의 엔티티 필드가있는 속성을 만들 수 있습니까? 여기 symfony 생성 양식의 레이블 수정
->add('companies', 'entity', array(
'label' => 'Company',
'class' => 'Default\Bundle\Entity\Customer',
'property' => 'accountId' + 'name', // I want to combine my entity fields here
'multiple' => true,
'expanded' => true,
'query_builder' => function ($repository)
그냥 참조
class Customer
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @Assert\NotBlank(message="Please enter a Customer ID.")
* @Assert\Length(max="32")
* @ORM\Column(type="string", length=32)
* @var string
*/
protected $accountId;
/**
* @Assert\NotBlank(message="Please enter a company name.")
* @Assert\Length(max="60")
* @ORM\Column(type="string", length=60)
* @var string
*/
protected $name;
그리고 마지막으로 한 시간 동안 엔티티 :
->add('companies', 'entity', array(
'label' => 'Company',
'class' => 'Default\Bundle\Entity\Customer',
'property' => 'accountId', //This puts the company id next to the check box
'multiple' => true,
'expanded' => true,
'query_builder' => function ($repository)
{
return $repository->createQueryBuilder('c')->orderBy('c.accountId', 'ASC');
},))
->add('Save', 'submit')
->getForm();
이것은 내가 뭘하려고 오전입니다 : 여기 내 컨트롤러 내 양식이다. .. 나는 이것에서 가고 싶다 :
이에:
최고 찾고있는 다음 http://symfony.com/doc/current/reference/forms/types/entity.html#choice-label을 양식 필드 값을 유지하고 싶다면! 양식을 작성할 때 함수를 참조 할 수 있는지 몰랐습니다. 나는 그것이 클래스의 변수가되어야한다고 생각했다. –