0
Symfony 양식에서 내 엔티티 필드를 추가 할 때 엔티티 주석이 매핑되고이 필드에 기반하여 Symfony 추측을 기반으로합니다. 필자의 필드가 nullable인지 아닌지, 이와 덤프 등 :Symfony forms, 연관 필드에 필수 속성이 맞춰 짐
public 'fieldMappings' =>
array (size=5)
'acl' =>
array (size=9)
'fieldName' => string 'acl' (length=3)
'type' => string 'smallint' (length=8)
'scale' => int 0
'length' => null
'unique' => boolean false
'nullable' => boolean true
'precision' => int 0
'options' =>
array (size=2)
...
'columnName' => string 'acl' (length=3)
'id' =>
array (size=10)
'fieldName' => string 'id' (length=2)
'type' => string 'integer' (length=7)
'scale' => int 0
'length' => null
'unique' => boolean true
'nullable' => boolean false
'precision' => int 0
'options' =>
array (size=2)
...
'columnName' => string 'id' (length=2)
'id' => boolean true
하지만 관련 분야 (외래 키)가있는 경우, 심포니는 다른 매핑 구조를 가지고 있으며, 필드 등이 덤프와 같은, null 허용 여부 될 수 있다면 생각하지 않습니다
를public 'associationMappings' =>
array (size=3)
'userObj' =>
array (size=19)
'fieldName' => string 'userObj' (length=7)
'joinColumns' =>
array (size=1)
...
'cascade' =>
array (size=0)
...
'inversedBy' => null
'targetEntity' => string 'AdminBundle\Entity\User' (length=23)
'fetch' => int 2
'type' => int 2
'mappedBy' => null
'isOwningSide' => boolean true
'sourceEntity' => string 'AdminBundle\Entity\UserAcl' (length=26)
'isCascadeRemove' => boolean false
'isCascadePersist' => boolean false
'isCascadeRefresh' => boolean false
'isCascadeMerge' => boolean false
'isCascadeDetach' => boolean false
'sourceToTargetKeyColumns' =>
array (size=1)
...
'joinColumnFieldNames' =>
array (size=1)
...
'targetToSourceKeyColumns' =>
array (size=1)
...
'orphanRemoval' => boolean false
'storeObj' =>
array (size=19)
'fieldName' => string 'storeObj' (length=8)
'joinColumns' =>
array (size=1)
...
'cascade' =>
array (size=0)
...
'inversedBy' => null
'targetEntity' => string 'AdminBundle\Entity\Store' (length=24)
'fetch' => int 2
'type' => int 2
'mappedBy' => null
'isOwningSide' => boolean true
'sourceEntity' => string 'AdminBundle\Entity\UserAcl' (length=26)
'isCascadeRemove' => boolean false
'isCascadePersist' => boolean false
'isCascadeRefresh' => boolean false
'isCascadeMerge' => boolean false
'isCascadeDetach' => boolean false
'sourceToTargetKeyColumns' =>
array (size=1)
...
'joinColumnFieldNames' =>
array (size=1)
...
'targetToSourceKeyColumns' =>
array (size=1)
...
'orphanRemoval' => boolean false
이러한 경우 필요한 속성은 다음과 같이 구성해야합니다. m 그렇지 않으면 true (Symfony 양식의 기본값)입니다.
누구나 Symfony가 이러한 경우에 필요한 속성을 어떻게 추측 할 수 있는지 알고 있습니까?
/**
* @ORM\ManyToOne(targetEntity="User")
* @ORM\JoinColumn(name="fk_user", referencedColumnName="id", nullable=false, unique=false, onDelete="CASCADE")
*/
private $userObj;
/**
* @ORM\ManyToOne(targetEntity="Store")
* @ORM\JoinColumn(name="fk_store", referencedColumnName="id", nullable=false, unique=false, onDelete="CASCADE")
*/
private $storeObj;
답해 주셔서 감사합니다. 지금은 이것을하고 있지만, Symfony가 나머지 작업과 마찬가지로이 작업을 수행하면 좋을 것입니다. –