New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in MongoDB types #31

Closed
salehsed opened this Issue Oct 18, 2011 · 27 comments

Comments

Projects
None yet
4 participants
@salehsed

salehsed commented Oct 18, 2011

I'm trying to create an admin for The User document in FosUserBundle. That document has a "role" attribute that the type is "hash"
And when the admin controller tries to show the page , it'll throw

An exception has been thrown during the rendering of a template ("The dbType "hash" is not yet implemented") in "ListBuilderAction.php.twig" at line 73. 
@cedriclombardot

This comment has been minimized.

Show comment
Hide comment
@cedriclombardot

cedriclombardot Oct 18, 2011

Member

hash is not a dbtype !! That means the field guesser have not find the model type. see : https://github.com/cedriclombardot/AdmingeneratorGeneratorBundle/blob/master/Guesser/DoctrineODMFieldGuesser.php

It's normally take the dbType from doctrine mapping. If it's doesn't work, you could add in your yaml :

fields:
   hashField:
      dbType: string
Member

cedriclombardot commented Oct 18, 2011

hash is not a dbtype !! That means the field guesser have not find the model type. see : https://github.com/cedriclombardot/AdmingeneratorGeneratorBundle/blob/master/Guesser/DoctrineODMFieldGuesser.php

It's normally take the dbType from doctrine mapping. If it's doesn't work, you could add in your yaml :

fields:
   hashField:
      dbType: string
@cedriclombardot

This comment has been minimized.

Show comment
Hide comment
@cedriclombardot

cedriclombardot Oct 18, 2011

Member

In fact hash seems really be a type ! https://github.com/FriendsOfSymfony/FOSUserBundle/blob/master/Resources/config/doctrine/User.mongodb.xml

Could you try to complete the guesser ?? probably with a "collection" dbType ??

Member

cedriclombardot commented Oct 18, 2011

In fact hash seems really be a type ! https://github.com/FriendsOfSymfony/FOSUserBundle/blob/master/Resources/config/doctrine/User.mongodb.xml

Could you try to complete the guesser ?? probably with a "collection" dbType ??

@salehsed

This comment has been minimized.

Show comment
Hide comment
@salehsed

salehsed Oct 18, 2011

I'll work on it

salehsed commented Oct 18, 2011

I'll work on it

@cedriclombardot

This comment has been minimized.

Show comment
Hide comment
@cedriclombardot

cedriclombardot Oct 18, 2011

Member

Thx for to link, i ll try to implement all fields.

Could you do it for hash ? My mongo db env is down tonight i've a fatal doctrine/mongodb-odm#175

Member

cedriclombardot commented Oct 18, 2011

Thx for to link, i ll try to implement all fields.

Could you do it for hash ? My mongo db env is down tonight i've a fatal doctrine/mongodb-odm#175

@salehsed

This comment has been minimized.

Show comment
Hide comment
@salehsed

salehsed Oct 25, 2011

Now I'm not sure how to do that .
@cedriclombardot: did you find any chance to do it ?

salehsed commented Oct 25, 2011

Now I'm not sure how to do that .
@cedriclombardot: did you find any chance to do it ?

@cedriclombardot

This comment has been minimized.

Show comment
Hide comment
@cedriclombardot

cedriclombardot Oct 26, 2011

Member

For me there is only to update https://github.com/cedriclombardot/AdmingeneratorGeneratorBundle/blob/master/Guesser/DoctrineODMFieldGuesser.php switchs to add the hash case hash in getFormType et getFilterType

Member

cedriclombardot commented Oct 26, 2011

For me there is only to update https://github.com/cedriclombardot/AdmingeneratorGeneratorBundle/blob/master/Guesser/DoctrineODMFieldGuesser.php switchs to add the hash case hash in getFormType et getFilterType

@salehsed

This comment has been minimized.

Show comment
Hide comment
@salehsed

salehsed Nov 9, 2011

Is it possible for you to add the "hash" forms and the gusser + filters

salehsed commented Nov 9, 2011

Is it possible for you to add the "hash" forms and the gusser + filters

@cedriclombardot

This comment has been minimized.

Show comment
Hide comment
@cedriclombardot

cedriclombardot Nov 9, 2011

Member

i ll work on it this week

Member

cedriclombardot commented Nov 9, 2011

i ll work on it this week

@salehsed

This comment has been minimized.

Show comment
Hide comment
@salehsed

salehsed Nov 9, 2011

Thanks , you're a life saver

salehsed commented Nov 9, 2011

Thanks , you're a life saver

cedriclombardot added a commit that referenced this issue Nov 11, 2011

cedriclombardot added a commit that referenced this issue Nov 11, 2011

@cedriclombardot

This comment has been minimized.

Show comment
Hide comment
@cedriclombardot

cedriclombardot Nov 11, 2011

Member

@salehsed it's ok for hash i'll will look for other fields

Member

cedriclombardot commented Nov 11, 2011

@salehsed it's ok for hash i'll will look for other fields

@salehsed

This comment has been minimized.

Show comment
Hide comment
@salehsed

salehsed Nov 11, 2011

@cedriclombardot that's awesome.
please also check the "Add" button under hash type (on the form), because it's not working

salehsed commented Nov 11, 2011

@cedriclombardot that's awesome.
please also check the "Add" button under hash type (on the form), because it's not working

@cedriclombardot

This comment has been minimized.

Show comment
Hide comment
@cedriclombardot

cedriclombardot Nov 11, 2011

Member

It's works for me ! Have you got a js error ?? Have you publish assets before ? Do you use a specific theme ActiveAdmin or original or your own ??

Member

cedriclombardot commented Nov 11, 2011

It's works for me ! Have you got a js error ?? Have you publish assets before ? Do you use a specific theme ActiveAdmin or original or your own ??

@salehsed

This comment has been minimized.

Show comment
Hide comment
@salehsed

salehsed Nov 11, 2011

We used custom template and extend the blocks
in app/Resources/views/base_admin_assetic_less.html.twig

{% extends "::base.html.twig" %}

{% block main %}


<div id="content">
    {% block flashes %}
                {% if app.session.flash('success') %}
    <div class="notification_box success">
                        {{ app.session.flash('success') }}
        </div>
                {% endif %}
                {% if app.session.flash('error') %}
        <div class="notification_box error">
                        {{ app.session.flash('error') }}
        </div>
                {% endif %}
            {% endblock %}

            {% block body %}{% endblock %}
        </div>
{% endblock %}

        {% block stylesheets %}
            <link rel="stylesheet" href="{{ asset('/bundles/admingeneratorgenerator/css/all.css') }}" type="text/css" media="all" />
            <!--[if IE]>
                <link href="{{ asset('/bundles/admingeneratorgenerator/css/ie.css') }}" rel="stylesheet" type="text/css" />
            <![endif]-->
        {% endblock %}

salehsed commented Nov 11, 2011

We used custom template and extend the blocks
in app/Resources/views/base_admin_assetic_less.html.twig

{% extends "::base.html.twig" %}

{% block main %}


<div id="content">
    {% block flashes %}
                {% if app.session.flash('success') %}
    <div class="notification_box success">
                        {{ app.session.flash('success') }}
        </div>
                {% endif %}
                {% if app.session.flash('error') %}
        <div class="notification_box error">
                        {{ app.session.flash('error') }}
        </div>
                {% endif %}
            {% endblock %}

            {% block body %}{% endblock %}
        </div>
{% endblock %}

        {% block stylesheets %}
            <link rel="stylesheet" href="{{ asset('/bundles/admingeneratorgenerator/css/all.css') }}" type="text/css" media="all" />
            <!--[if IE]>
                <link href="{{ asset('/bundles/admingeneratorgenerator/css/ie.css') }}" rel="stylesheet" type="text/css" />
            <![endif]-->
        {% endblock %}
@cedriclombardot

This comment has been minimized.

Show comment
Hide comment
@cedriclombardot

cedriclombardot Nov 11, 2011

Member

Ok so you have to add a jquery because the add code is :

    $(document).ready(function() {

                type_collection_hashField_nextId = $('#edit_movie_hashField > div').length;

        $('#type_collection_hashField .new').click(function() {
           var prototype = $('#edit_movie_hashField').attr('data-prototype');
           prototype = prototype.replace(/\$\$name\$\$/g, type_collection_hashField_nextId);
           type_collection_hashField_nextId++;
           $('#edit_movie_hashField').append(prototype);

                      $('#edit_movie_hashField > div:last').append("<a class=\"delete\"> </a>");

           $('#edit_movie_hashField .delete').click(function() { //@todo make a function for this
               $(this).parent('div').remove();
            });
                   });

                    $('#edit_movie_hashField > div').append("<a class=\"delete\"> </a>");

            $('#edit_movie_hashField .delete').click(function() {
               $(this).parent('div').remove();
            });
Member

cedriclombardot commented Nov 11, 2011

Ok so you have to add a jquery because the add code is :

    $(document).ready(function() {

                type_collection_hashField_nextId = $('#edit_movie_hashField > div').length;

        $('#type_collection_hashField .new').click(function() {
           var prototype = $('#edit_movie_hashField').attr('data-prototype');
           prototype = prototype.replace(/\$\$name\$\$/g, type_collection_hashField_nextId);
           type_collection_hashField_nextId++;
           $('#edit_movie_hashField').append(prototype);

                      $('#edit_movie_hashField > div:last').append("<a class=\"delete\"> </a>");

           $('#edit_movie_hashField .delete').click(function() { //@todo make a function for this
               $(this).parent('div').remove();
            });
                   });

                    $('#edit_movie_hashField > div').append("<a class=\"delete\"> </a>");

            $('#edit_movie_hashField .delete').click(function() {
               $(this).parent('div').remove();
            });
@salehsed

This comment has been minimized.

Show comment
Hide comment
@salehsed

salehsed Nov 11, 2011

is there any way to make the js more general , because it seems to just work with "MOVIE" scenario
because the selectors are using

$('#edit_movie_hashField > div')

salehsed commented Nov 11, 2011

is there any way to make the js more general , because it seems to just work with "MOVIE" scenario
because the selectors are using

$('#edit_movie_hashField > div')

@cedriclombardot

This comment has been minimized.

Show comment
Hide comment
@cedriclombardot

cedriclombardot Nov 11, 2011

Member

The js is auto generated ;) so it correspond automatically with you field look into your source you will see thats correspond to your field name https://github.com/cedriclombardot/AdmingeneratorGeneratorBundle/blob/master/Resources/templates/CommonAdmin/EditTemplate/Type/collection.php.twig

Member

cedriclombardot commented Nov 11, 2011

The js is auto generated ;) so it correspond automatically with you field look into your source you will see thats correspond to your field name https://github.com/cedriclombardot/AdmingeneratorGeneratorBundle/blob/master/Resources/templates/CommonAdmin/EditTemplate/Type/collection.php.twig

@salehsed

This comment has been minimized.

Show comment
Hide comment
@salehsed

salehsed Nov 11, 2011

can you tell me which twig block is getting the js codes ?

salehsed commented Nov 11, 2011

can you tell me which twig block is getting the js codes ?

@cedriclombardot

This comment has been minimized.

Show comment
Hide comment
@cedriclombardot

cedriclombardot Nov 11, 2011

Member

I m not sure to understand about wich block you speack,

The field block is form_{youtFieldName} open the file in your app/cache/dev/Admingenerated/.... to see
The main js eg jquery is loaded in the theme https://github.com/cedriclombardot/AdmingeneratorGeneratorBundle/blob/master/Resources/views/base_admin_assetic_less.html.twig block javascripts

Member

cedriclombardot commented Nov 11, 2011

I m not sure to understand about wich block you speack,

The field block is form_{youtFieldName} open the file in your app/cache/dev/Admingenerated/.... to see
The main js eg jquery is loaded in the theme https://github.com/cedriclombardot/AdmingeneratorGeneratorBundle/blob/master/Resources/views/base_admin_assetic_less.html.twig block javascripts

@madarco

This comment has been minimized.

Show comment
Hide comment
@madarco

madarco Jan 25, 2012

I have a similar problem, but with the Collection field type:

/** @MongoDB\Collection */
private $serviceTypes = array();

I get this error:

An exception has been thrown during the rendering of a template ("Notice: Undefined index: targetDocument in /mnt/www/commercialista/symfony/vendor/bundles/Admingenerator/GeneratorBundle/Guesser/DoctrineODMFieldGuesser.php line 167") in ListBuilderAction.php.twig at line 125.

I am missing something?

madarco commented Jan 25, 2012

I have a similar problem, but with the Collection field type:

/** @MongoDB\Collection */
private $serviceTypes = array();

I get this error:

An exception has been thrown during the rendering of a template ("Notice: Undefined index: targetDocument in /mnt/www/commercialista/symfony/vendor/bundles/Admingenerator/GeneratorBundle/Guesser/DoctrineODMFieldGuesser.php line 167") in ListBuilderAction.php.twig at line 125.

I am missing something?

@cedriclombardot

This comment has been minimized.

Show comment
Hide comment
@cedriclombardot

cedriclombardot Jan 30, 2012

Member

Is it possible to have a Collection without targetDocument parameter in doctrine ? I tink your line should like

    /**
     * @MongoDB\Colelction(targetDocument="Admingenerator\DoctrineODMDemoBundle\Document\Producer")
     */
Member

cedriclombardot commented Jan 30, 2012

Is it possible to have a Collection without targetDocument parameter in doctrine ? I tink your line should like

    /**
     * @MongoDB\Colelction(targetDocument="Admingenerator\DoctrineODMDemoBundle\Document\Producer")
     */
@madarco

This comment has been minimized.

Show comment
Hide comment
@madarco

madarco Jan 30, 2012

Yes, it maps to an array of strings. (eg: a list of tags)

It is especially useful with MongoDb for his support of "Multikeys": http://www.mongodb.org/display/DOCS/Multikeys

madarco commented Jan 30, 2012

Yes, it maps to an array of strings. (eg: a list of tags)

It is especially useful with MongoDb for his support of "Multikeys": http://www.mongodb.org/display/DOCS/Multikeys

@cedriclombardot

This comment has been minimized.

Show comment
Hide comment
@cedriclombardot

cedriclombardot Jan 30, 2012

Member

Finally what is the difference with hash ?

is "Multikeys" collection :

{ 
name: "Warm Weather",
author: "Steve", 
tags: ['weather', 'hot', 'record', 'april']
} 

isn't an object with a field name, author and an hash tags ? in an odm ?

Member

cedriclombardot commented Jan 30, 2012

Finally what is the difference with hash ?

is "Multikeys" collection :

{ 
name: "Warm Weather",
author: "Steve", 
tags: ['weather', 'hot', 'record', 'april']
} 

isn't an object with a field name, author and an hash tags ? in an odm ?

@madarco

This comment has been minimized.

Show comment
Hide comment
@madarco

madarco Jan 31, 2012

The type "Collection" is like the Hash but with numeric indexes.

In your example the document class would be:

class Book {
  /** @MongoDB\String */
  private $name;

  /** @MongoDB\String */
  private $name;

  /** @MongoDB\Collection */
  private $tags = array();
}

Also notice that the Collection doesn't have the targetDocument attribute (Unlike ReferenceMany: http://www.doctrine-project.org/docs/mongodb_odm/1.0/en/reference/reference-mapping.html)

madarco commented Jan 31, 2012

The type "Collection" is like the Hash but with numeric indexes.

In your example the document class would be:

class Book {
  /** @MongoDB\String */
  private $name;

  /** @MongoDB\String */
  private $name;

  /** @MongoDB\Collection */
  private $tags = array();
}

Also notice that the Collection doesn't have the targetDocument attribute (Unlike ReferenceMany: http://www.doctrine-project.org/docs/mongodb_odm/1.0/en/reference/reference-mapping.html)

@cedriclombardot

This comment has been minimized.

Show comment
Hide comment
@madarco

This comment has been minimized.

Show comment
Hide comment
@madarco

madarco Jan 31, 2012

If it can help, I've (partially) fixed the issue with:

fields:
  services:
    dbType: hash
    formType: choice

However in the List its displayed only "Array" in the services column and the update doesn't work.

madarco commented Jan 31, 2012

If it can help, I've (partially) fixed the issue with:

fields:
  services:
    dbType: hash
    formType: choice

However in the List its displayed only "Array" in the services column and the update doesn't work.

@neoshadybeat

This comment has been minimized.

Show comment
Hide comment
@neoshadybeat

neoshadybeat Aug 20, 2012

Member

issue closed

Member

neoshadybeat commented Aug 20, 2012

issue closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment