sonata-project / SonataDoctrineMongoDBAdminBundle

Symfony Sonata / Integrate Doctrine MongoDB ODM into the SonataAdminBundle
https://docs.sonata-project.org/projects/SonataDoctrineMongoDBAdminBundle
MIT License
65 stars 95 forks source link

Hash Type and Admin ? #233

Closed foji2 closed 7 years ago

foji2 commented 7 years ago

Environment

"php": ">=5.5.9",
        "doctrine/doctrine-bundle": "^1.6",
        "doctrine/doctrine-migrations-bundle": "^1.0",
        "doctrine/mongodb-odm": "^1.1",
        "doctrine/mongodb-odm-bundle": "^3.3",
        "doctrine/orm": "^2.5",
        "friendsofsymfony/user-bundle": "~2.0",
        "sonata-project/admin-bundle": "3.*",
        "sonata-project/doctrine-mongodb-admin-bundle": "^3.24.0",
        "symfony/symfony": "3.3.*",

Hello I got a problem i have a document Place :

    /**
     * @MongoDB\Field(name="address", type="hash")
     */
    protected $address;

{ 
    "_id" : ObjectId("4864765465465"), 
    "address" : {
        "postal_code" : "01300", 
        "street" : "av. Test", 
        "city" : "Test", 
        "country" : "France"
    }, 
    "name" : "test", 
    "state" : NumberInt(0), 
    "coordinates" : {
        "longitude" : 45.21, 
        "latitude" : 5.6136
    }
}

I have install sonata admin and i want use form

so I try

  protected function configureFormFields(FormMapper $formMapper)
    {
        $formMapper
            ->add('name')
            ->add('address.street')
            ->add('state')
    }

    protected function configureDatagridFilters(DatagridMapper $datagridMapper)
    {
        $datagridMapper->add('name');
        $datagridMapper->add('state');

    }

    protected function configureListFields(ListMapper $listMapper)
    {
        $listMapper->addIdentifier('name', 'text', array('label' => 'Name'));
        $listMapper->addIdentifier('address.street');
        $listMapper->addIdentifier('state', 'text', array('label' => 'State'));
    }

But this not work i check log and got :

request.CRITICAL: Uncaught PHP Exception Symfony\Component\Debug\Exception\ContextErrorException: "Notice: Undefined index: address" at /var/www/html/dev/myproject/vendor/sonata-project/doctrine-mongodb-admin-bundle/Sonata/DoctrineMongoDBAdminBundle/Model/ModelManager.php line 69

How i can do that ?

Thanks you

core23 commented 7 years ago

We try to keep github issues for feature requests and bugs only.

Please have a look at the docs or use StackOverflow for general support and questions.

Btw this is not possible:

protected function configureFormFields(FormMapper $formMapper)
    {
        $formMapper
            ->add('address.street')
foji2 commented 7 years ago

It s a bug address is an array so it must be possible to add form field ...

I check the docs and hash is never explain so ?

foji2 commented 7 years ago

in the docs 👍

namespace Acme\AcmeBundle\Admin;

class UserAdmin extends Admin
{
    protected function configureListFields(ListMapper $listMapper)
    {
        $listMapper
            ->addIdentifier('id')
            ->add('firstName')
            ->add('lastName')
            ->add('address.street')
            ->add('address.ZIPCode')
            ->add('address.town')
        ;
    }
}

So why this not work for me ?

Thanks

core23 commented 7 years ago

The docs are talking about configureListFields