sonata-project / SonataAdminBundle

The missing Symfony Admin Generator
https://docs.sonata-project.org/projects/SonataAdminBundle
MIT License
2.11k stars 1.26k forks source link

Link to child action #5660

Closed danaki closed 4 years ago

danaki commented 5 years ago

src/Admin/ProductQuestionAdmin.php

namespace App\Admin;

use App\Entity\ProductQuestion;
use KunicMarko\SonataAutoConfigureBundle\Annotation\AdminOptions;

/**
 * @AdminOptions(
 *     label="Вопросы",
 *     group="Для продуктов",
 *     entity=ProductQuestion::class,
 *     children={"App\Admin\ProductQuestionAnswerAdmin"}
 * )
 */
class ProductQuestionAdmin extends AbstractAdmin
{
   ...
    /**
     * @param ListMapper $listMapper
     */
    protected function configureListFields(ListMapper $listMapper)
    {
        $listMapper
            ->add('id', null, ['label' => '#ID'])
            ->add('_action', 'actions', [
                'label' => ' ',
                'actions' => [
                    'edit' => [],
                    'delete' => [],
                    'list_question_answers' => [
                        'template' => 'admin/CRUD/list__action_list_question_answers.html.twig'
                    ]
                ],
            ]);
    }
    ...
}

src/Admin/ProductQuestionAnswerAdmin.php

namespace App\Admin;

use App\Entity\ProductQuestionAnswer;
use KunicMarko\SonataAutoConfigureBundle\Annotation\AdminOptions;

/**
 * @AdminOptions(
 *     label="Ответы",
 *     group="Для продуктов",
 *     entity=ProductQuestionAnswer::class
 * )
 */
class ProductQuestionAnswerAdmin extends AbstractAdmin
{
    protected $parentAssociationMapping = 'question';

templates/admin/CRUD/list__action_list_question_answers.html

<a class="btn btn-sm btn-default" href="{{ admin.getChild('App\\Admin\\ProductQuestionAnswerAdmin').generateUrl('list') }}">
    Ответы
</a>

Produces:

An exception has been thrown during the rendering of a template ("Parameter "id" for route "admin_app_productquestion_productquestionanswer_list" must match "[^/]++" ("" given) to generate a corresponding URL.").

Environment

Sonata packages

sonata-project/admin-bundle              3.x-dev 855118f dev-master ef06d3e The missing Symfony Admin Generator
sonata-project/block-bundle              3.16.0          3.16.0             Symfony SonataBlockBundle
sonata-project/cache                     2.0.1           2.0.1              Cache library
sonata-project/core-bundle               3.17.0          3.17.0             Symfony SonataCoreBundle
sonata-project/datagrid-bundle           2.5.0           3.0.0              Symfony SonataDatagridBundle
sonata-project/doctrine-extensions       1.3.0           1.3.0              Doctrine2 behavioral extensions
sonata-project/doctrine-orm-admin-bundle 3.10.0          3.10.0             Symfony Sonata / Integrate Doctrine ORM into the SonataAdminBundle
sonata-project/exporter                  2.0.1           2.0.1              Lightweight Exporter library

Symfony packages

symfony/asset                      v4.3.3  v4.3.3  Symfony Asset Component
symfony/browser-kit                v4.3.3  v4.3.3  Symfony BrowserKit Component
symfony/cache                      v4.3.3  v4.3.3  Symfony Cache component with PSR-6, PSR-16, and tags
symfony/cache-contracts            v1.1.5  v1.1.5  Generic abstractions related to caching
symfony/config                     v4.3.3  v4.3.3  Symfony Config Component
symfony/console                    v4.3.3  v4.3.3  Symfony Console Component
symfony/css-selector               v4.3.3  v4.3.3  Symfony CssSelector Component
symfony/debug                      v4.3.3  v4.3.3  Symfony Debug Component
symfony/debug-bundle               v4.3.3  v4.3.3  Symfony DebugBundle
symfony/debug-pack                 v1.0.7  v1.0.7  A debug pack for Symfony projects
symfony/dependency-injection       v4.3.3  v4.3.3  Symfony DependencyInjection Component
symfony/doctrine-bridge            v4.3.3  v4.3.3  Symfony Doctrine Bridge
symfony/dom-crawler                v4.3.3  v4.3.3  Symfony DomCrawler Component
symfony/dotenv                     v4.3.3  v4.3.3  Registers environment variables from a .env file
symfony/event-dispatcher           v4.3.3  v4.3.3  Symfony EventDispatcher Component
symfony/event-dispatcher-contracts v1.1.5  v1.1.5  Generic abstractions related to dispatching event
symfony/expression-language        v4.3.3  v4.3.3  Symfony ExpressionLanguage Component
symfony/filesystem                 v4.3.3  v4.3.3  Symfony Filesystem Component
symfony/finder                     v4.3.3  v4.3.3  Symfony Finder Component
symfony/flex                       v1.4.5  v1.4.5  Composer plugin for Symfony
symfony/form                       v4.3.3  v4.3.3  Symfony Form Component
symfony/framework-bundle           v4.3.3  v4.3.3  Symfony FrameworkBundle
symfony/http-foundation            v4.3.3  v4.3.3  Symfony HttpFoundation Component
symfony/http-kernel                v4.3.3  v4.3.3  Symfony HttpKernel Component
symfony/inflector                  v4.3.3  v4.3.3  Symfony Inflector Component
symfony/intl                       v4.3.3  v4.3.3  A PHP replacement layer for the C intl extension that includes additional data from the ICU library.
symfony/maker-bundle               v1.12.0 v1.12.0 Symfony Maker helps you create empty commands, controllers, form classes, tests and more so you can forget about wr...
symfony/mime                       v4.3.3  v4.3.3  A library to manipulate MIME messages
symfony/monolog-bridge             v4.3.3  v4.3.3  Symfony Monolog Bridge
symfony/monolog-bundle             v3.4.0  v3.4.0  Symfony MonologBundle
symfony/options-resolver           v4.3.3  v4.3.3  Symfony OptionsResolver Component
symfony/orm-pack                   v1.0.6  v1.0.6  A pack for the Doctrine ORM
symfony/phpunit-bridge             v4.3.3  v4.3.3  Symfony PHPUnit Bridge
symfony/polyfill-intl-icu          v1.11.0 v1.11.0 Symfony polyfill for intl's ICU-related data and classes
symfony/polyfill-intl-idn          v1.11.0 v1.11.0 Symfony polyfill for intl's idn_to_ascii and idn_to_utf8 functions
symfony/polyfill-mbstring          v1.11.0 v1.11.0 Symfony polyfill for the Mbstring extension
symfony/polyfill-php72             v1.11.0 v1.11.0 Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions
symfony/polyfill-php73             v1.11.0 v1.11.0 Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions
symfony/process                    v4.3.3  v4.3.3  Symfony Process Component
symfony/profiler-pack              v1.0.4  v1.0.4  A pack for the Symfony web profiler
symfony/property-access            v4.3.3  v4.3.3  Symfony PropertyAccess Component
symfony/property-info              v4.3.3  v4.3.3  Symfony Property Info Component
symfony/routing                    v4.3.3  v4.3.3  Symfony Routing Component
symfony/security-acl               v3.0.2  v3.0.2  Symfony Security Component - ACL (Access Control List)
symfony/security-bundle            v4.3.3  v4.3.3  Symfony SecurityBundle
symfony/security-core              v4.3.3  v4.3.3  Symfony Security Component - Core Library
symfony/security-csrf              v4.3.3  v4.3.3  Symfony Security Component - CSRF Library
symfony/security-guard             v4.3.3  v4.3.3  Symfony Security Component - Guard
symfony/security-http              v4.3.3  v4.3.3  Symfony Security Component - HTTP Integration
symfony/serializer                 v4.3.3  v4.3.3  Symfony Serializer Component
symfony/serializer-pack            v1.0.2  v1.0.2  A pack for the Symfony serializer
symfony/service-contracts          v1.1.5  v1.1.5  Generic abstractions related to writing services
symfony/stopwatch                  v4.3.3  v4.3.3  Symfony Stopwatch Component
symfony/templating                 v4.3.3  v4.3.3  Symfony Templating Component
symfony/test-pack                  v1.0.6  v1.0.6  A pack for functional and end-to-end testing within a Symfony app
symfony/translation                v4.3.3  v4.3.3  Symfony Translation Component
symfony/translation-contracts      v1.1.5  v1.1.5  Generic abstractions related to translation
symfony/twig-bridge                v4.3.3  v4.3.3  Symfony Twig Bridge
symfony/twig-bundle                v4.3.3  v4.3.3  Symfony TwigBundle
symfony/validator                  v4.3.3  v4.3.3  Symfony Validator Component
symfony/var-dumper                 v4.3.3  v4.3.3  Symfony mechanism for exploring and dumping PHP variables
symfony/var-exporter               v4.3.3  v4.3.3  A blend of var_export() + serialize() to turn any serializable data structure to plain PHP code
symfony/web-link                   v4.3.3  v4.3.3  Symfony WebLink Component
symfony/web-profiler-bundle        v4.3.3  v4.3.3  Symfony WebProfilerBundle
symfony/web-server-bundle          v4.3.3  v4.3.3  Symfony WebServerBundle
symfony/webpack-encore-bundle      v1.6.2  v1.6.2  Integration with your Symfony app & Webpack Encore!
symfony/workflow                   v4.3.3  v4.3.3  Symfony Workflow Component
symfony/yaml                       v4.3.3  v4.3.3  Symfony Yaml Component```

#### PHP version

PHP 7.3.7 (cli) (built: Jul 5 2019 12:44:05) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.3.7, Copyright (c) 1998-2018 Zend Technologies with Zend OPcache v7.3.7, Copyright (c) 1999-2018, by Zend Technologies

stale[bot] commented 4 years ago

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.