Developed with love by KnpLabs Hire us for your project!
21

SonataAdminBundle

by orocrm

SonataAdminBundle - The missing Symfony2 Admin Generator

Build Status

The online documentation of the bundle is in http://sonata-project.org/bundles/admin

The demo website can be found in http://demo.sonata-project.org/admin/dashboard (admin as user and password)

For contribution to the documentation you can find it on Resources/doc.

Warning: documentation files are not rendering correctly in Github (reStructuredText format)
and some content might be broken or hidden, make sure to read raw files.

Warning: The bundle has been split into 4 bundles :

Google Groups: For questions and proposals you can post on this google groups

Quick example

Defining an Admin class is pretty easy: simply define configure[Show|Form|List|Datagrid]Fields methods
(Fields in add function must be fields of your entity)

<?php
namespace Sonata\NewsBundle\Admin;

use Sonata\AdminBundle\Admin\Admin;
use Sonata\AdminBundle\Form\FormMapper;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Show\ShowMapper;

class PostAdmin extends Admin
{
    public function configureShowFields(ShowMapper $showMapper)
    {
        $showMapper
            ->add('author')
            ->add('enabled')
            ->add('title')
            ->add('abstract')
            ->add('content')
            ->add('tags')
        ;
    }

    public function configureFormFields(FormMapper $formMapper)
    {
        $formMapper
            ->with('General')
                ->add('enabled', null, array('required' => false))
                ->add('author', 'sonata_type_model', array(), array('edit' => 'list'))
                ->add('title')
                ->add('abstract')
                ->add('content')
            ->end()
            ->with('Tags')
                ->add('tags', 'sonata_type_model', array('expanded' => true))
            ->end()
            ->with('Options', array('collapsed' => true))
                ->add('commentsCloseAt')
                ->add('commentsEnabled', null, array('required' => false))
            ->end()
        ;
    }

    public function configureListFields(ListMapper $listMapper)
    {
        $listMapper
            ->addIdentifier('title')
            ->add('author')
            ->add('enabled')
            ->add('tags')
            ->add('commentsEnabled')
        ;
    }

    public function configureDatagridFilters(DatagridMapper $datagridMapper)
    {
        $datagridMapper
            ->add('title')
            ->add('enabled')
            ->add('tags', null, array('filter_field_options' => array('expanded' => true, 'multiple' => true)))
        ;
    }
}

Screenshots : http://www.dropbox.com/gallery/581816/2/BaseApplicationBundle/preview?h=59b2e8

Of course, power users will be happy as an Admin class is very flexible as all dependencies are
injected by the DIC (dependency injection container).

Features

  • Dashboard

  • List

    • Automatic sort
    • Link to associated admin (Post => User)
    • Custom templates
    • Row Action : edit, view, ...
    • Batch Action
    • Clever row visualisation : boolean values are represented with 'check picture'
    • Filter
    • Pagination
  • Edit/Create

    • Inline edition
    • Association management (create related model with + icon)
    • Group fields
    • Sortable option
    • Modal window to select model (when the list can be important)
    • Dynamic form on [one|many]-to-many association (add new element)
  • Templating

    • base templates (field, list, filter) can be overwritten
    • layout templates can be defined into the Service Container
  • Others

    • Nested Admin, ie /news/post/5/comment/list : filter and create comments only for the post with id=5
    • Contextual Breadcrumb
    • persistent parameters across an Admin
    • side menu option
    • Translated into 22 languages : BG, CA, CS, DE, EN, ES, EU, FA, FR, HR, IT, JA, LB, NL, PL, PT, PT_BR, RU, SK, SL, UK and zh_CN.
    • Built to be extended
    • Explain command line utility

Usage examples

TODO

  • create the ODM version
  • save filter criteria
  • export list
The MIT License

Copyright (c) 2010-2011 thomas.rabaix@sonata-project.org

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

///////////////////////////////////////////////////////////////////////////////

Silk icon set 1.3
_________________________________________
Mark James
http://www.famfamfam.com/lab/icons/silk/
_________________________________________

This work is licensed under a
Creative Commons Attribution 2.5 License.
[ http://creativecommons.org/licenses/by/2.5/ ]

This means you may use it for any purpose,
and make any changes you like.
All I ask is that you include a link back
to this page in your credits.

Are you using this icon set? Send me an email
(including a link or picture if available) to
mjames@gmail.com

Any other questions about this icon set please
contact mjames@gmail.com

///////////////////////////////////////////////////////////////////////////////

jQuery Form Plugin
version: 2.64 (25-FEB-2011)
@requires jQuery v1.3.2 or later

Examples and documentation at: http://malsup.com/jquery/form/
Dual licensed under the MIT and GPL licenses:
http://www.opensource.org/licenses/mit-license.php
http://www.gnu.org/licenses/gpl.html

Note : MIT license is applied in this bundle

///////////////////////////////////////////////////////////////////////////////
sonata_admin:
security:
handler: sonata.admin.security.handler.noop
information:

# Prototype
id: []
admin_permissions:

# Defaults:
- CREATE
- LIST
- DELETE
- UNDELETE
- EXPORT
- OPERATOR
- MASTER
object_permissions:

# Defaults:
- VIEW
- EDIT
- DELETE
- UNDELETE
- OPERATOR
- MASTER
- OWNER
title: Sonata Admin
title_logo: bundles/sonataadmin/logo_title.png
dashboard:
groups:

# Prototype
id:
label: ~
label_catalogue: ~
items: []
item_adds: []
blocks:
type: ~
settings:

# Prototype
id: []
position: right
admin_services:

# Prototype
id:
model_manager: ~
form_contractor: ~
show_builder: ~
list_builder: ~
datagrid_builder: ~
translator: ~
configuration_pool: ~
router: ~
validator: ~
security_handler: ~
label: ~
templates:
user_block: SonataAdminBundle:Core:user_block.html.twig
layout: SonataAdminBundle::standard_layout.html.twig
ajax: SonataAdminBundle::ajax_layout.html.twig
dashboard: SonataAdminBundle:Core:dashboard.html.twig
list: SonataAdminBundle:CRUD:list.html.twig
show: SonataAdminBundle:CRUD:show.html.twig
edit: SonataAdminBundle:CRUD:edit.html.twig
preview: SonataAdminBundle:CRUD:preview.html.twig
history: SonataAdminBundle:CRUD:history.html.twig
history_revision: SonataAdminBundle:CRUD:history_revision.html.twig
action: SonataAdminBundle:CRUD:action.html.twig
list_block: SonataAdminBundle:Block:block_admin_list.html.twig
short_object_description: SonataAdminBundle:Helper:short-object-description.html.twig
delete: SonataAdminBundle:CRUD:delete.html.twig
batch: SonataAdminBundle:CRUD:list__batch.html.twig
batch_confirmation: SonataAdminBundle:CRUD:batch_confirmation.html.twig
inner_list_row: SonataAdminBundle:CRUD:list_inner_row.html.twig
base_list_field: SonataAdminBundle:CRUD:base_list_field.html.twig
extensions:

# Prototype
id:
admins: []
excludes: []
implements: []
extends: []
instanceof: []
persist_filters: false
  • CRM-138: Upgrade Symfony to version 2.3
    By Ivan Klymenko, 3 years ago
  • Merge pull request #1402 from EmmanuelVella/choose
    By rande, 3 years ago
  • Add row selector for sonata_type_model_list
    By emmanuelvella, 3 years ago
  • Merge pull request #1399 from EmmanuelVella/patch-8
    By rande, 3 years ago
  • Set min-height on sonata_type_model_list css
    By emmanuelvella, 3 years ago
  • Fix unit tests
    By rande, 3 years ago
  • Fix form template regression
    By rande, 3 years ago
  • Update UPGRADE-2.2.md
    By rande, 3 years ago
  • Merge pull request #1395 from caponica/master
    By rande, 3 years ago
  • Update UPGRADE-2.1.md
    By caponica, 3 years ago
  • Fix composer.json config for exporter
    By rande, 3 years ago
  • Fix deprecated call
    By rande, 3 years ago
  • Fix revision layout
    By rande, 3 years ago
  • Merge pull request #1390 from tiagojsag/list_date_format
    By rande, 3 years ago
  • Merge pull request #1388 from 77web/translation-ja
    By rande, 3 years ago
  • custom date and datetime formats in show
    By tiagojsag, 3 years ago
  • documentation
    By tiagojsag, 3 years ago
  • custom date and datetime formats in list
    By tiagojsag, 3 years ago
  • [translation][ja] tweaks for Japanese translation
    By 77web, 3 years ago
  • [translation][ja] add missing Japanese translation
    By 77web, 3 years ago
  • Merge pull request #1367 from sjopet/patch-5
    By rande, 3 years ago
  • Merge pull request #1386 from pulzarraider/native_label_translator_fix
    By rande, 3 years ago
  • Merge pull request #1384 from EmmanuelVella/preview
    By rande, 3 years ago
  • Update composer.json
    By rande, 3 years ago
  • Fix NativeLabelTranslatorStrategy whitespace bug
    By pulzarraider, 3 years ago
  • Merge pull request #1385 from pulzarraider/timezone_unittest_fix
    By rande, 3 years ago
  • Fix falling unit tests in SonataAdminExtensionTest
    By pulzarraider, 3 years ago
  • Update preview mode
    By emmanuelvella, 3 years ago
  • Merge pull request #1383 from pulzarraider/admin_extension_fix
    By rande, 3 years ago
  • Added unit tests, added show_currency and show_percent template
    By pulzarraider, 3 years ago