1+ <?php
2+
3+ namespace Devtronic \CmsBundle \Admin ;
4+
5+ use Devtronic \CmsBundle \Form \MenuItemTargetType ;
6+ use Sonata \AdminBundle \Admin \Admin ;
7+ use Sonata \AdminBundle \Datagrid \DatagridMapper ;
8+ use Sonata \AdminBundle \Datagrid \ListMapper ;
9+ use Sonata \AdminBundle \Form \FormMapper ;
10+ use Sonata \AdminBundle \Show \ShowMapper ;
11+
12+ class MenuItemAdmin extends Admin
13+ {
14+
15+
16+ // Fields to be shown on create/edit forms
17+ protected function configureFormFields (FormMapper $ formMapper )
18+ {
19+ $ formMapper
20+ ->with ('label.cms.admin.menu_item_generic ' , array ('class ' => 'col-md-9 ' ))
21+ ->add ('title ' , null , array (
22+ 'label ' => 'label.cms.admin.menu_item_title ' ,
23+ ))
24+ ->add ('menu ' , null , array (
25+ 'label ' => 'label.cms.admin.menu ' ,
26+ ))
27+ ->add ('parentItem ' , null , array (
28+ 'label ' => 'label.cms.admin.menu_item_parent ' ,
29+ ))
30+ ->end ()
31+ ->with ('label.cms.admin.menu_item_target ' , array ('class ' => 'col-md-3 ' ))
32+ ->add ('type ' , MenuItemTargetType::class, array (
33+ 'label ' => 'label.cms.admin.menu_item_type ' ,
34+ ))
35+ ->add ('targetPage ' , null , array (
36+ 'label ' => 'label.cms.admin.menu_item_target_page ' ,
37+ ))
38+ ->add ('targetUrl ' , null , array (
39+ 'label ' => 'label.cms.admin.menu_item_target_address '
40+ ))
41+ ->end ()
42+ ;
43+ }
44+
45+
46+ // Fields to be shown on filter forms
47+ protected function configureDatagridFilters (DatagridMapper $ datagridMapper )
48+ {
49+ $ datagridMapper ->add ('type ' , null , array (
50+ 'label ' => 'label.cms.admin.menu_item_type ' ,
51+ ), MenuItemTargetType::class)
52+ ;
53+ }
54+
55+ // Fields to be shown on lists
56+ protected function configureListFields (ListMapper $ listMapper )
57+ {
58+ $ listMapper
59+ ->addIdentifier ('title ' , null , array (
60+ 'label ' => 'label.cms.admin.menu_item_title ' ,
61+ ))
62+ ->add ('parentItem ' , null , array (
63+ 'label ' => 'label.cms.admin.menu_item_parent ' ,
64+ ))
65+ ->add ('menu ' , null , array (
66+ 'label ' => 'label.cms.admin.menu ' ,
67+ ))
68+ ;
69+ }
70+
71+ }
0 commit comments