Reputation: 86
I use Symfony2 with SonataAdminBundle, and I have a problem where I add a Tab with sonata_type_admin Entity edit. If I go to Entity edit page - all right, but if I add field in OneToOne relationship on tab layout not loaded and all in one style.
Reading documentation not help me, I don't found this decision of this problem in settings. Please, help me.
Main object edit
$formMapper
->tab('Основная информация')
->with('Данные клуба', ['class' => 'col-md-8'])
->add('name', 'text', array('label' => 'Название'))
->add('alias', 'text', array('label' => 'alias в url на сайте'))
->add('logo', 'text', ['label' => 'Логотип'])
->add('description', 'textarea', ['label' => 'Описание клуба'])
->end()
->with('Основные настройки', ['class' => 'col-md-4'])
->add('type', 'entity', [
'label' => 'Тип клуба',
'class' => 'PbmozgSiteBundle:ClubType',
'query_builder' => function(EntityRepository $repository) {return $repository->createQueryBuilder('ClubType')->orderBy('ClubType.id', 'ASC');},
'property' => 'name',
'empty_value' => 'Выберите тип клуба',
'required' => false
]
)
->add('enabled', 'checkbox', ['label' => 'Включен'])
->add('vip', 'checkbox', ['label' => 'VIP'])
->add('rating', 'text', [
'label' => 'Рейтинг клуба',
'read_only' => true,
'disabled' => true,
]
)
->end()
->end()
->tab('Контактная информация')
->with('Контакты')
->add('contacts', 'sonata_type_admin', ['required' => false, 'delete' => false, 'btn_add' => false])
->end()
->end();
;
And subobject with add data
$formMapper
->with('Способы связи', ['class' => 'col-md-4'])
->add('phones', 'collection',
[
'label' => 'Телефоны',
'type' => new ClubPhonesListType(),
'required' => false,
'allow_add' => true,
'allow_delete' => true,
'attr' => ['class' => 'emails-list'],
'options' => ['label' => ' ', 'required' => false],
],
[
'edit' => 'inline',
'inline' => 'table',
'sortable' => 'position',
])
->add('emails', 'collection',
[
'label' => 'Электронная почта',
'type' => new ClubEmailsListType(),
'required' => false,
'allow_add' => true,
'allow_delete' => true,
'attr' => ['class' => 'emails-list'],
'options' => ['label' => ' ', 'required' => false],
],
[
'edit' => 'inline',
'inline' => 'table',
'sortable' => 'position',
])
->end()
->with('Геоданные', ['class' => 'col-md-4'])
->add('latitude', 'text', ['label' => 'Широта'])
->add('longitude', 'text', ['label' => 'Долгота'])
->add('polygon', 'text', ['label' => 'Полигон на карте'])
->add('country', 'text', ['label' => 'Город'])
->add('region', 'text', ['label' => 'Регион'])
->add('city', 'text', ['label' => 'Город'])
->add('address', 'text', ['label' => 'Полный адрес'])
->end()
->with('WEB', ['class' => 'col-md-4'])
->add('site', 'text', ['label' => 'Адрес сайта'])
->end()
;
Upvotes: 4
Views: 2397
Reputation: 274
I have the same problem. I found this :
Section 8.2 :
To do:
how to embed one Admin in another (1:1, 1:M, M:M)
So, I think for the moment there are no solution ? :/
Upvotes: 1