Closed 3kynox closed 8 years ago
That all seems to work for me, but my tests aren't using a database. Are you sure Doctrine is giving you a Mobile object? If you dump it before the form is created, what do you get?
Hello and thanks for help (again ^^)
Doctrine not giving Mobiles but Telephones, that explain why there is nothing related to Mobile.
What I first did is to set a fourth type in MoyenComm.orm.yml :
brunoBundle\Entity\MoyenComm:
type: entity
table: null
repositoryClass: brunoBundle\Entity\MoyenCommRepository
inheritanceType: JOINED
discriminatorColumn:
name: type
type: integer
discriminatorMap:
1: Telephone
2: Email
3: Adresse
4: Mobile
id:
id:
type: integer
id: true
generator:
strategy: AUTO
manyToOne:
contact:
targetEntity: Contact
inversedBy: moyensComm
lifecycleCallbacks: { }
After I modify in database one Telephone entry, to set it with type Mobile (type 4) and that phone number got a smsing checkbox now in form.
But I'm kind of out of logic here, because how I set other telephone numbers to mobile or the inverse ? No checkbox available for other phone numbers so not possible.
I'm looking actually at another inheritance doctrine type : MappedSuperClass.
With this, Telephones will have Mobile field 'smsing'. But that don't work.
Here is the mapping info now :
// Back to initial state
brunoBundle\Entity\MoyenComm:
type: entity
table: null
repositoryClass: brunoBundle\Entity\MoyenCommRepository
inheritanceType: JOINED
discriminatorColumn:
name: type
type: integer
discriminatorMap:
1: Telephone
2: Email
3: Adresse
id:
id:
type: integer
id: true
generator:
strategy: AUTO
manyToOne:
contact:
targetEntity: Contact
inversedBy: moyensComm
lifecycleCallbacks: { }
and Telephone orm :
brunoBundle\Entity\Telephone:
type: MappedSuperClass
table: null
repositoryClass: brunoBundle\Entity\TelephoneRepository
fields:
numero:
type: string
length: 255
OneToOne:
mappedRelated1:
targetEntity: brunoBundle\Entity\Mobile
joinColumn:
name: id
referencedColumnName: id
onDelete: cascade
lifecycleCallbacks: { }
But it returns error :
> C:\wamp\bin\php\php5.5.12\php.exe app/console doctrine:mapping:info
Found 7 mapped entities:
[OK] brunoBundle\Entity\Adresse
[OK] brunoBundle\Entity\Contact
[OK] brunoBundle\Entity\Email
[FAIL] brunoBundle\Entity\Mobile
Class "brunoBundle\Entity\Telephone" sub class of "brunoBundle\Entity\MoyenComm" is not a valid entity or mapped super class.
[OK] brunoBundle\Entity\MoyenComm
[FAIL] brunoBundle\Entity\Telephone
Class "brunoBundle\Entity\Telephone" sub class of "brunoBundle\Entity\MoyenComm" is not a valid entity or mapped super class.
[OK] brunoBundle\Entity\WebLink
Process finished with exit code 1 at 11:38:14.
Execution time: 3 126 ms.
I can't provide support for Doctrine or Symfony in general. Do you have any more questions about InfiniteFormBundle specifically?
Not yet. Thanks anyway, I'll sort this doctrine issue out.
Hello again,
I face currently another problem about defining "_sub-sub-type_".
If i re-take my last example available at https://github.com/infinite-networks/InfiniteFormBundle/issues/48, I got a main formType MoyenCommType that countains childrens :
Now I wish to extends TelephoneType -> MobileType
Then :
I finally updated database and added a first entry in the mobile table.
Now I try to get that value from my polycollection theme, prototype exists but that children appears nowhere from my dumps.
Any idea ?