List field definition ===================== These fields are used to display the information inside the list table. ã“れらã®ãƒ•ã‚£ãƒ¼ãƒ«ãƒ‰ã¯ãƒªã‚¹ãƒˆãƒ†ãƒ¼ãƒ–ル内ã«æƒ…å ±ã‚’è¡¨ç¤ºã™ã‚‹ç‚ºã«ä½¿ã‚ã‚Œã¾ã™ã€‚ Example ------- .. code-block:: php <?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 { protected function configureListFields(ListMapper $listMapper) { $listMapper ->addIdentifier('title') ->add('author') ->add('enabled') ->add('tags') ->add('commentsEnabled') // add custom action links ->add('_action', 'actions', array( 'actions' => array( 'view' => array(), 'edit' => array(), ) )) ; } } Types available --------------- The most important option for each field is the ``type``: The available types include: ãã‚Œãžã‚Œã®ãƒ•ã‚£ãƒ¼ãƒ«ãƒ‰ã«ãŠã„ã¦æœ€ã‚‚é‡è¦ãªã‚ªãƒ—ション㯠``type`` ã§ã‚ã‚Šã€ä»¥ä¸‹ã®ã‚‚ã®ãŒåˆ©ç”¨å¯èƒ½ã§ã™ã€‚ * boolean * datetime * decimal * identifier * integer * many_to_one : a link will be added to the related edit action (関連ã—ãŸeditアクションã«ãƒªãƒ³ã‚¯ãŒè¿½åŠ ã•ã‚Œã‚‹) * string * text * date * time If no type is set, the ``Admin`` class will use the type defined in the doctrine mapping definition. ã‚‚ã—タイプãŒã‚»ãƒƒãƒˆã•ã‚Œãªã‘れ㰠``Admin`` クラスã¯doctrineã®ãƒžãƒƒãƒ”ング定義ã«ã‚ˆã‚Šæ±ºã‚られãŸã‚¿ã‚¤ãƒ—を使ã„ã¾ã™ã€‚ List Actions ------------ You can set actions for the list items by adding an '_action' field in ``configureListFields`` ( ``configureListFields`` ä¸ã« '_action' ãƒ•ã‚£ãƒ¼ãƒ«ãƒ‰ã‚’è¿½åŠ ã™ã‚‹ã“ã¨ã«ã‚ˆã‚Šã€ãƒªã‚¹ãƒˆã‚¢ã‚¤ãƒ†ãƒ ã«ã‚¢ã‚¯ã‚·ãƒ§ãƒ³ã‚’セットã™ã‚‹ã“ã¨ãŒã§ãã¾ã™): .. code-block:: php <?php $listMapper->add('_action', 'actions', array( 'actions' => array( 'view' => array(), 'edit' => array(), ) )) Edit and delete actions are enabled in the default configuration. You can add your own! Default template file is: ``SonataAdminBundle:CRUD:list__action_[ACTION_NAME].html.twig`` デフォルトè¨å®šã§ã¯editã¨deleteアクションã¯æœ‰åŠ¹ã«ãªã£ã¦ã„ã¾ã™ã€‚ã‚ãªãŸã¯è‡ªåˆ†ã®ã‚’ã‚¢ã‚¯ã‚·ãƒ§ãƒ³ã‚’è¿½åŠ ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚デフォルトテンプレートファイル㯠``SonataAdminBundle:CRUD:list__action_[ACTION_NAME].html.twig`` ã§ã™ã€‚ You can specify your own by setting up the 'template' option like so: 次ã®ã‚ˆã†ã« 'テンプレート' オプションをセットアップã™ã‚‹ã“ã¨ã§è‡ªèº«ã®ãƒ†ãƒ³ãƒ—レートを記述ã™ã‚‹ã“ã¨ã‚‚ã§ãã¾ã™ã€‚ .. code-block:: php <?php $listMapper->add('_action', 'actions', array( 'actions' => array( 'view' => array(), 'edit' => array(), 'delete' => array('template' => 'MyBundle:MyController:my_partial.html.twig'), ) )) Advance Usage ------------- Displaying sub entity properties (åエンティティã®ãƒ—ãƒãƒ‘ティを表示ã™ã‚‹) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ If you need to display only one field from a sub entity in a dedicated column, you can simply use the dot-separated notation (note that this only makes sense when the prefix path is made of entities, not collections): ã‚‚ã—ã€åエンティティã‹ã‚‰ä¸€ã¤ã®ãƒ•ã‚£ãƒ¼ãƒ«ãƒ‰ã ã‘表示ã™ã‚‹å¿…è¦ãŒã‚ã‚Œã°ã€å˜ç´”ã«ãƒ‰ãƒƒãƒˆã§åŒºåˆ‡ã£ãŸè¡¨è¨˜ã‚’使ã†ã“ã¨ãŒã§ãã¾ã™ã€‚ (接é 辞ã¨ã—ã¦ä»˜ãパスãŒã€collectionåž‹ã§ãªãã€ã‚¨ãƒ³ãƒ†ã‚£ãƒ†ã‚£ã‹ã‚‰ä½œã‚‰ã‚Œã¦ã„ã‚‹å ´åˆç†ã«ã‹ãªã£ã¦ã„ã¾ã™ã€‚) .. code-block:: php <?php namespace Acme\AcmeBundle\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 UserAdmin extends Admin { protected function configureListFields(ListMapper $listMapper) { $listMapper ->addIdentifier('id') ->addIdentifier('firstName') ->addIdentifier('lastName') ->addIdentifier('address.street') ->addIdentifier('address.ZIPCode') ->addIdentifier('address.town') ; } } Custom template ^^^^^^^^^^^^^^^ If you need a specific layout for a row cell, you can define a custom template ã‚‚ã—行セルã«ãŸã„ã—ã¦ç‰¹åˆ¥ãªãƒ¬ã‚¤ã‚¢ã‚¦ãƒˆãŒå¿…è¦ã§ã‚ã‚Œã°ã€ã‚«ã‚¹ã‚¿ãƒ テンプレートを定義ã™ã‚‹ã“ã¨ã‚‚ã§ãã¾ã™ã€‚ .. code-block:: php <?php namespace Sonata\MediaBundle\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 MediaAdmin extends Admin { protected function configureListFields(ListMapper $listMapper) { $listMapper ->addIdentifier('id') ->add('image', 'string', array('template' => 'SonataMediaBundle:MediaAdmin:list_image.html.twig')) ->add('custom', 'string', array('template' => 'SonataMediaBundle:MediaAdmin:list_custom.html.twig')) ; } } The related template (関連ã—ãŸãƒ†ãƒ³ãƒ—レート) : .. code-block:: jinja {% extends 'SonataAdminBundle:CRUD:base_list_field.html.twig' %} {% block field%} <div> <strong>{{ object.name }}</strong> <br /> {{ object.providername}} : {{ object.width }}x{{ object.height }} <br /> </div> {% endblock %}