{"action":"closed","issue":{"url":"https://api.github.com/repos/sonata-project/SonataAdminBundle/issues/2702","labels_url":"https://api.github.com/repos/sonata-project/SonataAdminBundle/issues/2702/labels{/name}","comments_url":"https://api.github.com/repos/sonata-project/SonataAdminBundle/issues/2702/comments","events_url":"https://api.github.com/repos/sonata-project/SonataAdminBundle/issues/2702/events","html_url":"https://github.com/sonata-project/SonataAdminBundle/issues/2702","id":56171552,"number":2702,"title":"sonata_type_collection - clicking add button returns response but it isn't added to the page!","user":{"login":"Tocacar","id":878754,"avatar_url":"https://avatars.githubusercontent.com/u/878754?v=3","gravatar_id":"","url":"https://api.github.com/users/Tocacar","html_url":"https://github.com/Tocacar","followers_url":"https://api.github.com/users/Tocacar/followers","following_url":"https://api.github.com/users/Tocacar/following{/other_user}","gists_url":"https://api.github.com/users/Tocacar/gists{/gist_id}","starred_url":"https://api.github.com/users/Tocacar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Tocacar/subscriptions","organizations_url":"https://api.github.com/users/Tocacar/orgs","repos_url":"https://api.github.com/users/Tocacar/repos","events_url":"https://api.github.com/users/Tocacar/events{/privacy}","received_events_url":"https://api.github.com/users/Tocacar/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-02-01T18:02:40Z","updated_at":"2015-02-01T18:46:51Z","closed_at":"2015-02-01T18:46:51Z","body":"I have got this working fine on other admin classes, it's just this one class that this weird behaviour is happening for.  I've been through it a hundred times and can't figure it out:\r\n\r\n```\r\n//composer.json (the sonata bits) - ran update today\r\n\"sonata-project/cache-bundle\": \"2.2.*@dev\",\r\n        \"sonata-project/block-bundle\": \"2.2.*\",\r\n        \"sonata-project/admin-bundle\": \"2.3.*\",\r\n        \"sonata-project/core-bundle\": \"~2.3\",\r\n        \"sonata-project/exporter\": \"1.*\",\r\n        \"sonata-project/doctrine-orm-admin-bundle\": \"2.3.*\",\r\n        \"sonata-project/easy-extends-bundle\" : \"2.1.7\",\r\n        \"sonata-project/user-bundle\": \"2.3.*@dev\",\r\n        \"sonata-project/datagrid-bundle\": \"2.2.*@dev\",\r\n```\r\n\r\n\r\n```\r\n//LitterAdmin.php config\r\n\r\n//other stuff\r\n->add('pups', \r\n           'sonata_type_collection', array(\r\n                'by_reference' => false \r\n            ), array(\r\n                'edit' => 'inline',\r\n                'inline' => 'table'\r\n            )\r\n);\r\n\r\n```\r\n\r\n ```\r\n//Litter.php mapping\r\n\r\n    /**\r\n     * @var ArrayCollection $pups\r\n     *\r\n     * @ORM\\OneToMany(targetEntity=\"Mouse\", mappedBy=\"litter\", cascade={\"persist\"}, orphanRemoval=true)\r\n     */\r\n    private $pups;\r\n\r\n/**\r\n     * Add pup\r\n     *\r\n     * @param \\AMS\\ColonyBundle\\Entity\\Mouse $pup\r\n     * @return Litter\r\n     */\r\n    public function addPup(\\AMS\\ColonyBundle\\Entity\\Mouse $pup)\r\n    {\r\n        $this->pups[] = $pup;\r\n        $pup->setLitter($this);\r\n    \r\n        return $this;\r\n    }\r\n\r\n    /**\r\n     * Remove pup\r\n     *\r\n     * @param \\AMS\\ColonyBundle\\Entity\\Mouse $pup\r\n     */\r\n    public function removePup(\\AMS\\ColonyBundle\\Entity\\Mouse $pup)\r\n    {\r\n        $this->pups->removeElement($pup);\r\n    }\r\n\r\n    /**\r\n     * Get pups\r\n     *\r\n     * @return \\Doctrine\\Common\\Collections\\Collection \r\n     */\r\n    public function getPups()\r\n    {\r\n        return $this->pups;\r\n    }\r\n```\r\n\r\n```\r\n//Mouse.php mapping\r\n\r\n    /**\r\n     * @var integer $litter_id\r\n     *\r\n     * @ORM\\Column(name=\"litter_id\", type=\"integer\", nullable=true)\r\n     */\r\n    private $litter_id;\r\n\r\n    /**\r\n     * @ORM\\ManyToOne(targetEntity=\"Litter\", inversedBy=\"pups\")\r\n     * @ORM\\JoinColumn(name=\"litter_id\", referencedColumnName=\"id\")\r\n     */\r\n    protected $litter;\r\n\r\n    /**\r\n     * Set litter\r\n     *\r\n     * @param \\AMS\\ColonyBundle\\Entity\\Litter $litter\r\n     * @return Mouse\r\n     */\r\n    public function setLitter(\\AMS\\ColonyBundle\\Entity\\Litter $litter = null)\r\n    {\r\n        $this->litter = $litter;\r\n    \r\n        return $this;\r\n    }\r\n\r\n    /**\r\n     * Get litter\r\n     *\r\n     * @return \\AMS\\ColonyBundle\\Entity\\Litter \r\n     */\r\n    public function getLitter()\r\n    {\r\n        return $this->litter;\r\n    }\r\n\r\n```\r\n\r\nNow... in the LitterAdmin form, when I press the 'Add' button, this is the content of the POST response from Firebug:\r\n\r\n```\r\n              \r\n    <div id=\"field_container_s54ce677183ded_pups\" class=\"field-container\">\r\n        <span id=\"field_widget_s54ce677183ded_pups\" >\r\n                                                                        <table class=\"table table-bordered\">\r\n                            <thead>\r\n                                <tr>\r\n                                                                    </tr>\r\n                            </thead>\r\n                            <tbody class=\"sonata-ba-tbody\">\r\n                                                                    <tr>\r\n                                                                            </tr>\r\n                                                            </tbody>\r\n                        </table>\r\n                                                \r\n        </span>\r\n\r\n        \r\n                            <span id=\"field_actions_s54ce677183ded_pups\" >\r\n                    <a\r\n                        href=\"/admin/ams/colony/mouse/create?uniqid=s54ce6776da8f9&amp;code=ams.admin.mouse&amp;pcode=ams.admin.litter&amp;puniqid=s54ce677183ded\"\r\n                        onclick=\"return start_field_retrieve_s54ce677183ded_pups(this);\"\r\n                        class=\"btn btn-success btn-sm btn-outline sonata-ba-action\"\r\n                        title=\"Add new\"\r\n                        >\r\n                        <i class=\"fa fa-plus-circle\"></i>\r\n                        Add new\r\n                    </a>\r\n                </span>\r\n            \r\n                        \r\n                        \r\n\r\n\r\n\r\n<!-- edit one association -->\r\n\r\n<script type=\"text/javascript\">\r\n\r\n    // handle the add link\r\n    var field_add_s54ce677183ded_pups = function(event) {\r\n\r\n        event.preventDefault();\r\n        event.stopPropagation();\r\n\r\n        var form = jQuery(this).closest('form');\r\n\r\n        // the ajax post\r\n        jQuery(form).ajaxSubmit({\r\n            url: 'http://ams.ldev/admin/core/append-form-field-element?code=ams.admin.litter&elementId=s54ce677183ded_pups&uniqid=s54ce677183ded',\r\n            type: \"POST\",\r\n            dataType: 'html',\r\n            data: { _xml_http_request: true },\r\n            success: function(html) {\r\n                if (!html.length) {\r\n                    return;\r\n                }\r\n\r\n                jQuery('#field_container_s54ce677183ded_pups').replaceWith(html); // replace the html\r\n\r\n                Admin.shared_setup(jQuery('#field_container_s54ce677183ded_pups'));\r\n\r\n                if(jQuery('input[type=\"file\"]', form).length > 0) {\r\n                    jQuery(form).attr('enctype', 'multipart/form-data');\r\n                    jQuery(form).attr('encoding', 'multipart/form-data');\r\n                }\r\n                jQuery('#sonata-ba-field-container-s54ce677183ded_pups').trigger('sonata.add_element');\r\n                jQuery('#field_container_s54ce677183ded_pups').trigger('sonata.add_element');\r\n            }\r\n        });\r\n\r\n        return false;\r\n    };\r\n\r\n    var field_widget_s54ce677183ded_pups = false;\r\n\r\n    // this function initialize the popup\r\n    // this can be only done this way has popup can be cascaded\r\n    function start_field_retrieve_s54ce677183ded_pups(link) {\r\n\r\n        link.onclick = null;\r\n\r\n        // initialize component\r\n        field_widget_s54ce677183ded_pups = jQuery(\"#field_widget_s54ce677183ded_pups\");\r\n\r\n        // add the jQuery event to the a element\r\n        jQuery(link)\r\n            .click(field_add_s54ce677183ded_pups)\r\n            .trigger('click')\r\n        ;\r\n\r\n        return false;\r\n    }\r\n</script>\r\n\r\n<!-- / edit one association -->\r\n\r\n\r\n            </div>\r\n```\r\n\r\nBut nothing appears on the page!  No Firebug errors, and Symfony 2.6.3 debug bar doesn't register any AJAX action either.\r\n\r\nCan anyone see what's wrong with this?"}}