Giter Club home page Giter Club logo

sonatadoctrineormadminbundle's Introduction

SonataDoctrineORMAdminBundle

Integrate Doctrine ORM into the SonataAdminBundle

Latest Stable Version Latest Unstable Version Psalm Type Coverage License

Total Downloads Monthly Downloads Daily Downloads

Branch Github Actions Code Coverage Documentation
4.x Test Coverage Status Documentation Status
5.x Test Coverage Status Documentation Status

Documentation

Check out the documentation on the official website.

Support

For general support and questions, please use StackOverflow.

If you think you found a bug or you have a feature idea to propose, feel free to open an issue after looking at the contributing guide.

License

This package is available under the MIT license.

sonatadoctrineormadminbundle's People

Contributors

attilabukor avatar axzx avatar bladrak avatar core23 avatar dmaicher avatar emmanuelvella avatar eugenekurasov avatar franmomu avatar ggabrovski avatar gimler avatar greg0ire avatar jaimesuez avatar jordisala1991 avatar kunicmarko20 avatar oskarstark avatar peter-gribanov avatar petk avatar phansys avatar pulzarraider avatar rande avatar robertdolca avatar romain-geissler avatar sonataci avatar soullivaneuh avatar tiagojsag avatar toooni avatar vincentlanglet avatar wbloszyk avatar willemverspyck avatar zhil avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sonatadoctrineormadminbundle's Issues

Line added to builder/FormContractor.php breaks one-to-one inline edit

Line 133:
"$fieldDescription->setOption('edit','admin');"

overwrites " 'edit' => 'inline' " option. And breaks embedded forms in one to one relations.

Sample:
->add('my_field', 'sonata_type_admin', array(), array('required' => false, 'edit' => 'inline'))
Throws an exception:
An exception has been thrown during the rendering of a template ("Notice: Undefined offset: -1 in vendor/symfony/src/Symfony/Bridge/Twig/Extension/FormExtension.php line 245") in SonataDoctrineORMAdminBundle:CRUD:edit_orm_one_to_one.html.twig at line 37.

oneToMany - addComments VS addComment

I have defined two entities, Article and Comment:

class Article {
    /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;

    /**
     * @ORM\Column(type="text")
     */
    protected $some_text;

    /**
     * @ORM\OneToMany(targetEntity="Comment", mappedBy="article", cascade={"persist", "remove"})
     */
    protected $comments;
class Comment {
    /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;

    /**
     * @ORM\Column(type="text")
     */
    protected $some_text;

    /**
     * @ORM\ManyToOne(targetEntity="Article")
     */
    protected $article;

And in my Admin classes:

class ArticleAdmin extends Admin
{
    /**
     * @param \Sonata\AdminBundle\Form\FormMapper $formMapper
     *
     * @return void
     */
    protected function configureFormFields(FormMapper $formMapper)
    {
        $formMapper
                ->add('some_text', null, array('required' => false))
                ->add('comments', 'sonata_type_collection', array(), array(
                    'edit' => 'inline',
                    'inline' => 'table',
                    'sortable'  => 'position'
                ))
            ->end()
        ;
    }
class CommentAdmin extends Admin
{
    protected $parentAssociationMapping = 'article';
    /**
     * @param \Sonata\AdminBundle\Form\FormMapper $formMapper
     *
     * @return void
     */
    protected function configureFormFields(FormMapper $formMapper)
    {
        if(!$this->isChild()) {
            $formMapper->add('article', 'sonata_type_model', array(), array('edit' => 'list'));
        }
        $formMapper->add('some_text', null, array('required' => false))
        ->end()
        ;
    }

Everything woks but the add comment buttion in the edit article form.
It gives me this 500:
Please add a method addComments in the FalseFaro\SimpleSiteBundle\Entity\Article class!

If I look at the Article class a function addComment (without s) has been generated, but the one with the final S is missing.
If I add the function manually, the embedded Comment form is displayed when I hit the add button, but When I save, comment is saved but is not linked to the article.

Any clue?

Adding values to ManyToOne relation in form is not working on multiple associations

I have a form, where an entity is associated with another entity via a ManyToOne relation twice (so 2 choice fields).
I'm using the sonata_type_model - type with standard edit mode. If I add new value via the + button, it's added to the first select field correctly, but not the second one.

If I refresh the page, everything is displayed correctly. I browsed the code, but don't really have a clue to fix this. Any hints, so that I can fix this?

One-To-Many and sonata_type_collection - not adding related entity

Hi, I've two entities. connected via one-to-many. Editing 'one' entity I've sonata_type_collection fileds displaying 'Many' entities. Thanks to orphanRemoval and modifiable => true I can remove related entitites. When I press '+', I can add 'Many' entities, but Sonata doesn't set parent entitiy (in my case, transaction_id is always NULL). What am I doing wrong?

Submodel filtering not rendering template correctly

I'm trying to add a filter on an associated model, a one-to-one relation named dispatchOrder:

$datagridMapper
            ->add('dispatchOrder.orderNumber', null, array('label' => 'Order Number'))

Twig is unable to render the template, but the issue is the name of the field. FormView is throwing the following notice:

Notice: Undefined index: dispatchOrder.orderNumber in vendor/symfony/src/Symfony/Component/Form/FormView.php line 213

If you dump the FormView->children the name of the filter is "dispatchOrder~orderNumber", rather than "dispatchOrder.orderNumber". This renaming is done in Filter->getFormName() - but is obviously causing an issue here.

Any thoughts on this?

Date filter values are not being transformed in the filter method

I just updated my bundle to take advantage of the date filters and I'm getting the following exception:

Notice: Undefined offset: 0 in *snip*/vendor/doctrine/lib/Doctrine/ORM/Query.php line 307

Query->processParameterValue() is trying to loop over the array's values numerically, but the keys are text. For example, the value of the start date of a doctrine_orm_date_range filter is:

array
  'year' => string '2007' (length=4)
  'month' => string '1' (length=1)
  'day' => string '1' (length=1)

I noticed that in PR 45 the values were transformed prior to being passed as a parameter to the queryBuilder.

Can't use date fields in DatagridMapper

Trying to use date field in filters:

protected function configureDatagridFilters(DatagridMapper $datagridMapper)
{
$datagridMapper
->add('due_date', 'doctrine_orm_datetime_range');
}

Results in exception:

The option "input_type" does not exist. Known options are: "attr", "block_name", "by_reference", "cascade_validation", "compound", "constraints", "csrf_field_name", "csrf_protection", "csrf_provider", "data", "data_class", "disabled", "empty_data", "error_bubbling", "error_mapping", "extra_fields_message", "field_options", "field_type", "intention", "invalid_message", "label", "label_attr", "mapped", "max_length", "pattern", "post_max_size_message", "property_path", "read_only", "required", "sonata_admin", "sonata_field_description", "translation_domain", "trim", "validation_constraint", "validation_groups", "virtual"

Thrown by OptionsResolver::validateOptionsExistence

sortable column must be named position

If you don't name your sort-by column "position", drag-droppable lists do not display correctly. edit_orm_one_to_many.html.twig (line 105 currently) has a sortable column of 'position' hard coded in to the javascript. Instead of 'position' it should really sort by whichever field is specified in configureFormFields().

    $formMapper
        ->add('code')
        ->add('enabled')
        ->add('name')
        ->add('defaultFormat')
        ->add('galleryHasMedias', 'sonata_type_collection', array(), array(
            'edit' => 'inline',
            'inline' => 'table',
            'sortable'  => 'position' //<====drag-dropping only works if you specify "position" here, no other field name works
        ))
    ;

BUG: Sonata\DoctrineORMAdminBundle\Model\ModelManager find() method fails to manage composite primary keys

Sonata\DoctrineORMAdminBundle\Model\ModelManager find() method fails to manage composite primary keys.

I have an entity like this one:

Class Language
{

/**
 * @ORM\Id
 * @ORM\Column(type="string", length="25", nullable=false, unique=true, name="idioma") 
 */
private $idioma;

/**
 * @ORM\Id
 * @ORM\Column(type="string", length="6", nullable=false, unique=false, name="lang_code") 
 */
private $langCode;

/** @var string */
private $locale;

}

And when i tried to insert, through SonaAdmin, a new Entity into de DataBase which is linked to Language i get the following error:

Warning: array_combine(): Both parameters should have an equal number of elements in myProject/vendor/bundles/Sonata/DoctrineORMAdminBundle/Model/ModelManager.php line 176

Here is a bit of info:

echo $class;
myVendor\myBundleBundle\Entity\Language

print_r(explode(self::ID_SEPARATOR, $id));
Array
(
[0] => 1
)
print_r($this->getIdentifierFieldNames($class));
Array
(
[0] => idioma
[1] => langCode
)

The entity which fails to insert into the database and is linked to Language entity, looks like:

Class PlanaWeb_i18n
{
/**
* @Assert\Choice( choices = { "blank", "self"},message = "fooo.")
* @Orm\Column( type="string", length="13", name="type", nullable=false, name="target", columnDefinition="ENUM( 'blank', 'self' )" )
* @Assert\NotBlank()
*/
private $target;

/**
 *  @ORM\Id
 *  @ORM\ManyToOne( targetEntity="PlanaWeb", inversedBy="idiomas" )
 *  @ORM\JoinColumn( name="plana_web_id", nullable=false, referencedColumnName="id", onDelete="CASCADE" )
 */
private $planaWeb;

/**
 *  @ORM\Id
 *  @ORM\ManyToOne( targetEntity="Language" )
 *  @ORM\JoinColumn( name="lang_code", nullable=false, referencedColumnName="lang_code", onDelete="CASCADE" )
 */
private $idioma;

}

csrf_protection = false, config issue

Hello there

As soon as the config value framework.csrf_protection is set to false:

framework:
    csrf_protection: false

the list view throws the following error:

The option "csrf_protection" does not exist. Known options are: "virtual", "error_bubbling", "empty_data", "data", "data_class", "trim", "required", "read_only", "max_length", "pattern", "property_path", "by_reference", "error_bubbling", "error_mapping", "label", "attr", "invalid_message" and so on...

Removing the "array('csrf_protection' => false)" from the "createNamedBuilder" function call on

https://github.com/sonata-project/SonataDoctrineORMAdminBundle/blob/master/Builder/DatagridBuilder.php#L134

"solves" the problem, of course this is just a hack. Anyone having an idea how to solve this properly?

cc @dbu

Error while installing using Composer

For some reason while installing (updating) Composer package sonata-project/doctrine-orm-admin-bundle I got the following error:

[RuntimeException]                                                                                                              
  Failed to clone http://github.com/sonata-project/SonataDoctrineORMAdminBundle.git via git, https and http protocols, aborting.  

  - git://github.com/sonata-project/SonataDoctrineORMAdminBundle.git                                                              
    fatal: unable to overwrite old ref-pack file: Is a directory                                                                  

  - https://github.com/sonata-project/SonataDoctrineORMAdminBundle.git                                                            
    fatal: Fetch attempted without a local repo                                                                                   

  - http://github.com/sonata-project/SonataDoctrineORMAdminBundle.git                                                             
    fatal: Fetch attempted without a local repo

I tried again after removing the folder, but with no success. I had no issues with other packages. So maybe something is corrupt in the GitHub repo? Can someone reproduce it / test this package?

Thanks in advantage for a solution.

sonata_type_model has been broken

In Symfony 2.0 and branch 2.0 I used this for ManyToMany

->add('autor', 'sonata_type_model', array('required' => false, 'query' => $query_autor))

Now with Symfony 2.1 and master I have to use this:

->add('autor', 'sonata_type_model', array('required' => false, 'query' => $query_autor, 'multiple' => true))

The form field is shown, but when I select at least one element and click Update, I get an error:

this form should not contain extra fields

And my list field is shown 3 times in a form. All with this error. So int he place where field should be put, it is rendered 3 times.

I have managed to overcome this with this solution.

        $query_autor = $this->modelManager->getEntityManager('MyCompany\BooksBundle\Entity\Autor')->createQueryBuilder()
        ->add('select', 'a')
        ->add('from', 'MyCompany\BooksBundle\Entity\Autor a')
        ->add('orderBy', 'a.nazwisko ASC');

$formMapper
    ->add('autor', null, array('required' => false, 'query_builder' => $query_autor, 'multiple' => true))

so the Guesser worked and I had to change query to query_builder. But still sonata_type_model doesn't work

Oracle issue with DISTINCT in the queries

I am using Oracle database and having an issue when deleting or sorting the content as. I am getting the following errors: "ORA-00932: inconsistent datatypes: expected - got CLOB " and "ORA-00932: inconsistent datatypes: expected - got LOG"

Apparently use of DISTINCT is incompatible with LOG and CLOB datatypes in Oracle. According to a blog post by Ramkumar Menon from Oracle "A SELECT returning CLOB values must not use the DISTINCT clause." https://blogs.oracle.com/rammenon/entry/dbadapter_javasqlsqlexception

I was wondering if it would be possible to override the Pager, ProxyQuery and ModelManagers service/classes to remove the DISTINCT clause from the queries or what would be the best practice to resolve this issue and how. many Thanks.

Allow setting entity manager name in the model manager service

When using two entity managers, both mapping same bundle (same entity in different databases), then guessing manager based on class (see #36) can return the wrong manager.

It would be nice to specify directly the entity manager name in the model manager service.

enctype="multipart/form-data" not present while adding inline table with "file" inputs

I think that probably the bugs reported in the SonaAdminBundle project (sonata-project/SonataAdminBundle#677 and sonata-project/SonataAdminBundle#228) should have been reported into this project.

The problem is that when you add an inline table form that contains file fields, the enctype="multipart/form-data" is not set into the form until you add 2 inline forms, and then the files are not uploaded.

Please, let me know which information you need in order to debug this issue.

[Master] Deletion fails on one-to-many relation

Is anonye using this bundle on master and has not problems with deleting one-to-many relations?

Even the deletion of images from a SonataMediaBundle gallery fails, so it cant' be a problem with my setup. When deleting an entity from the PersistentCollection in a simple symfony2 controller, the entity is removed correctly.

However, when deleted through the sonata admin, deletion fails.

What i've found out so far is, that the owner property in the PersistentCollection is null when updating the entity in the SonataAdmin class.

When removing the entity manually, the owner is not null, and that's why deletion fails in the Admin class.

The check is done here.

If anyone has a hint why this is failing in master, i'd greatly appreciate it.

One-to-one relations not displayed correctly in list/show templates

If there is no AssociationAdmin defined for the field_description the value of the relation is never displayed.

From list_orm_one_to_one.html.twig:

{% block field %}
    {% if field_description.hasAssociationAdmin and field_description.associationadmin.id(value) %}
        {% if field_description.hasAssociationAdmin and field_description.associationadmin.isGranted('EDIT') and field_description.associationadmin.hasRoute('edit') %}
            <a href="{{ field_description.associationadmin.generateObjectUrl('edit', value) }}">{{ value|render_relation_element(field_description) }}</a>
        {% else %}
            {{ value|render_relation_element(field_description) }}
        {% endif %}
    {% endif %}
{% endblock %}

show_orm_*.html.twig Missing ?

Hello,

I'm trying to display in a show view a field that is a reference to another entity. In the view, the line is not present.

I've looked a little further and it looks like the show templates are not present, for example, here, the builder sets the template "SonataDoctrineORMAdminBundle:CRUD:show_orm_many_to_one.html.twig", but there is no such file :
https://github.com/sonata-project/SonataDoctrineORMAdminBundle/blob/master/Builder/ShowBuilder.php#L129

Is it still to be done or I'm I doing something wrong ?

If it has to be done, could you give me some guideline on what is to do, I tried to add the show_orm_many_to_one.html.twig in ~/Resources/views/CRUD but with no success.

thanks.

Delete integrity constraint violation

I am using an one-to-many relationship. When I delete an entry from one side of the relationship I get this error 'Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails'. As I saw DBALException is not caught in CRUDController.

Admin can not render sonata_type_model field if entity use single table inheritance

Just discovered admin can not render a form where i'm editing Comment that attached to News class, which have a single table inheritance (STI) with Article.
News class has admin class, while Article class obviously not.
After few hours of debugging i got that field which have STI have property hasAssociationAdmin set to false, so it rendered in another way than regular field with one-to-many.
If i create an admin class for Article field renders ok, but i do not want article class to appear in menu and services as it's useless.

Filter Field: doctrine_orm_callback

Dear Sonata Team,

I'am working with Admin Bundle and created own Filter Fields using doctrine_orm_callback.

If I follow the instructions on http://sonata-project.org/bundles/admin/master/doc/reference/filter_field_definition.html,
the Filter will be executed every time with the checkbox is checked.

protected function configureDatagridFilters(DatagridMapper $datagridMapper)
{
$datagridMapper
->add('with_open_comments', 'doctrine_orm_callback', array(
'callback' => array($this, 'getWithOpenCommentFilter'),
'field_type' => 'checkbox'
))
;
}

public function getWithOpenCommentFilter($queryBuilder, $alias, $field, $value)
{

    // FOR DEBUGGING
    print_r($value);

    if (!$value) {
        return;
    }

    $queryBuilder->leftJoin(sprintf('%s.comments', $alias), 'c');
    $queryBuilder->andWhere('c.status = :status');
    $queryBuilder->setParameter('status', Comment::STATUS_MODERATE);
}

If you debug the value of $value, you get the following Output:

not checked checkbox:
Array ( [type] => )

checked checkbox:
Array ( [type] => [value] => 1 )


So
if (!$value) {
return;
}
does not work and the Filter will always been active.

In my opion $value should be null the checkbox is not checked.

Datagrid filters : doctrine_orm_callback with join / batch action

I get the following error when using this callback and then try to use a batch action :

Iterate with fetch join in class Application\RealEstateBundle\Entity\Picture using association product not allowed.
function($queryBuilder, $alias, $field, $value) {
    $queryBuilder->leftJoin($alias.'.pictures', 'pic');

    if ((int) $value['value'] === 1) {
        $queryBuilder->andWhere('pic.id IS NOT NULL');
    } elseif ((int) $value['value'] === 2) {
        $queryBuilder->andWhere('pic.id IS NULL');
    }
}

I try to get all the products with / without pictures.

The association Acme\BlogBundle\Entity\Post#user refers to the inverse side field Application\Sonata\UserBundle\Entity\User#posts which does not exist.

The association Acme\BlogBundle\Entity\Post#user refers to the inverse side field Application\Sonata\UserBundle\Entity\User#posts which does not exist.
i have this error but in User Entity i have the property $posts

/**
* @Orm\OneToMany(targetEntity="\Acme\WelcomeBundle\Entity\Post", mappedBy="user")
*/
protected $posts;

public function __construct() {
    parent::__construct();
    $this->posts = new ArrayCollection();

}

maybe i have add this property in User.orm.xmp? IF yes , how can add?
thx

Wrong dependencies(?). symfony vs. symfony-framework.

I suggest to change dependency symfony/symfony for symfony/symfony-framework and eventually add some other depndencies if required. It is impossible to include this bundle as dependency (for dev) in another bundle. I can do it, but want to ask if there is any reason for current state.

Feature request: filtering collections

It would be a nice feature to optionally add 'where' conditions on mapped sonata_type_collections at least but I think it would be useful to implement on every listing stuff.

List view - _sort_order is always ASC

No matter how many times I click sort option in list view header, it is always an ASC

http://.../article/list?filter[_sort_order]=ASC&filter[_sort_by]=published&filter[_page]=1

Branch 2.0, Symfony 2.0.15

StringFilter does not escape % (percent sign) or _ (underscore)

It seems that Sonata\DoctrineORMAdminBundle\Filter\StringFilter does not filter % or _

I have tried something this :

if ($data['type'] == ChoiceType::TYPE_EQUAL) {
    $this->applyWhere($queryBuilder, sprintf('%s.%s %s :%s', $alias, $field, $operator, $parameterName));
    $queryBuilder->setParameter($parameterName, $data['value']);
} else {
    if ($data['type'] == ChoiceType::TYPE_CONTAINS) {
        $where = $queryBuilder->expr()->like(sprintf('%s.%s', $alias, $field), sprintf(':%s', $parameterName));
    } else if ($data['type'] == ChoiceType::TYPE_NOT_CONTAINS) {
        $where = $queryBuilder->expr()->not($queryBuilder->expr()->like(sprintf('%s.%s', $alias, $field), sprintf(':%s', $parameterName)));
    }
    $this->applyWhere($queryBuilder, $where);
    $queryBuilder->setParameter($parameterName, sprintf($this->getOption('format'), $queryBuilder->expr()->literal($data['value'], 'string')));
}

This example uses :

  • use expr()->like to create the like
  • use expr()->literal to escape _, %
    but literal does not work with the oci8 driver that I use.

Any idea ?

Overriding doctrine_orm.xml

Hi,

I tried to integrate SonataAdminBundle with SonataDoctrineORMAdminBundle to my project.
Everything worked quite well. But now I'm stuck.

doctrine_orm.xml defines sonata.admin.manager.orm with the entity manager to use. Now my problem is that I do not whant to use the default manager. Because I didn't find a config param to set the entitymanager I copied the file to my bundle and added

imports:
- { resource: "@MyBundle/Resources/config/doctrine_orm.xml" }

but when I do this I'll get the following error:

annot import resource "XXX/Symfony/app/config/." from "XXX/Symfony/app/config/routing.yml".

when I change the name of the entity manager in the original doctrine_orm.xml in the sonataDoctrineOrmAdminBundle then it works.

So my question is how can I define the entity manager the bundle will use. Or how can I properly override the sonata.admin.manager.orm service.

Thanks already, any hints appreciated.
franco

Using type boolean for datagrid filters results in exception (doctrine-orm, mongo)

Hi,

using a doctrine admin grid filter for MongoDB results in an exception when adding a boolean type filter:

protected function configureDatagridFilters(DatagridMapper $datagridMapper)
    {
        $datagridMapper
            ->add('aStringField') // works
            ->add('enabled', 'boolean'); // fails
    }

Exception: The type name specified for the service sonata.admin.form.type.boolean does not match the actual name

Location: vendor/symfony/symfony/src/Symfony/Component/Form/Extension/DependencyInjection/DependencyInjectionExtension.php at line 49

Possible solution:

If I use type "doctrine_orm_boolean" as filter field type, it works.

protected function configureDatagridFilters(DatagridMapper $datagridMapper)
    {
        $datagridMapper
            ->add('aStringField') // works
            ->add('enabled', 'doctrine_orm_boolean'); // works too
    }

Question: Should this be fixed, e.g. by implementing a getName() function returning sonata_type_boolean in Sonata\AdminBundle\Form\Type\BooleanType? Or is there another solution?

Thx
Sven

oneToMany relations without a join table don't persist

I would like to add the oneToMany relations in the entities edit screens.

I have, for example, these admin classes:
PhoneTypeAdmin
PhoneNumberAdmin
and one PhoneType has many PhoneNumbers, so the PhoneNumber class has the foreing key pointing the PhoneType.

The PhoneTypeAdmin configureFormFields function looks like this:

public function configureFormFields(FormMapper $formMapper)
{
    $formMapper
        // fields
        ->add('name')
        // oneToMany
        ->add('phoneNumbers', null, array(
            'required' => false
        ))
    ;
}

With this, what I see in the PhoneType edit screen is a multiple select box with the list of PhoneNumbers, which is great.
The problem is that if I click a PhoneNumber and press the Update button, the relation is not persisted.

I have read about the owner and inversed roles in doctrine's relations and I think my ".orm.yml" files are correct.

The doctrine definitions are:

#ExamplesExampleBundle/src/Examples/ExampleBundle/Resources/config/doctrine/PhoneType.orm.yml
Examples\ExampleBundle\Entity\PhoneType:
  type: entity
  table: phone_types
  fields:
    id:
      id: true
      type: integer
      unsigned: false
      nullable: false
      generator:
        strategy: SEQUENCE
    name:
      type: string
      length: null
      fixed: false
      nullable: false
  oneToMany:
    phoneNumbers:
      targetEntity: PhoneNumber
      mappedBy: phoneType
  lifecycleCallbacks: {  }
#ExamplesExampleBundle/src/Examples/ExampleBundle/Resources/config/doctrine/PhoneNumber.orm.yml
Examples\ExampleBundle\Entity\PhoneNumber:
  type: entity
  table: phone_numbers
  fields:
    id:
      id: true
      type: integer
      unsigned: false
      nullable: false
      generator:
        strategy: SEQUENCE
    phoneNumber:
      type: string
      length: null
      fixed: false
      nullable: false
      column: phone_number
  manyToOne:
    phoneType:
      targetEntity: PhoneType
      inversedBy: phoneNumbers
      joinColumns:
        phone_type_id:
          referencedColumnName: id
  lifecycleCallbacks: {  }

Any idea of what I'm missing?

Thanks

Filter options label doesn't work

Label for filters cannot be set as documentation says, it doesn't work

    ->add('tags', null, array('label' => 'les tags'), null, array('expanded' => true, 'multiple' => true)

Error "No entity manager defined for class Doctrine\ORM\PersistentCollection"

I have an entity with a OneToMany relation:

/**
 * @ORM\OneToMany(targetEntity="Time", mappedBy="version")
 */
public $times;

Adding it to an admin form using the default type works, so the relation is defined correctly.

However, adding it using type "sonata_type_model_list" is broken:

$formMapper->add('times', 'sonata_type_model_list')

I get the following error:

No entity manager defined for class Doctrine\ORM\PersistentCollection

Does anybody have an idea where this error comes from and how to solve it?

Installation documentation typo

On the installation page there is a little typo :

$loader->registerNamespaces(array(
    // ...
    'simplethings'      => __dir__.'/../vendor/bundles',
    // ...
));

I guess 'simplethings' should be CamelCase like this:

$loader->registerNamespaces(array(
    // ...
    'SimpleThings'      => __dir__.'/../vendor/bundles',
    // ...
));

not working add buttons when using sonata_type_collection

I have a field representing a One-to-many relation. In the configureFormFields function I have it defined lilke this (as explained in the documentation):

->add('groups', 'sonata_type_collection', array(), array(
    'edit' => 'inline',
    'inline' => 'standard',
))

In the corresponding field I see a green plus button but a click on it does nothing.

If I change the edit value to standard, then I can click the button an the popup appears, and I can create a new element for the relation. I keep on seeing only the green plus button. If I updated, the relation is saved, but then the edit page of this element appears without styles.

Why I can't see the selection box?

Composite keys and big table

Hi,

I use Sonata Admin as framework for one website administration and I'm having problem in the list view of a new entity. We use Doctrine ORM with MySQL.

The entity is something like this: http://pastie.org/private/sgqzexzaaghnj33ty1fuw

Currently the table in MySQL has more than 100k rows and it's optimized for our use (composite index bucket+checksum).

When I open the Sonata Admin's list view for the entity, it keeps loading forever. Looks like it's trying to load the entire table in memory, even if I set maxPerPage to 10 in the admin class.

I looked into the logs and the last query in the log is to select ALL rows in the table's entity, without limits.

How can I fix this? Does Sonata Admin have some proper idiom to solve this kind of problem?

thanks!

Primary key with "-" Throws warning

I Have a primary key like : 515-666-2902-077228-y9YD

And I get when I try to open the associated dataset a Warning like:

Warning: array_combine() [function.array-combine]: Both parameters should have an equal number of elements in /Users/torsten/Sites/dmr/vendor/bundles/Sonata/DoctrineORMAdminBundle/Model/ModelManager.php line 135

The Problem comes from:

/Users/torsten/Sites/dmr/vendor/bundles/Sonata/DoctrineORMAdminBundle/Model/ModelManager.php at line 135
*/
public function find($class, $id)
{
$values = array_combine($this->getIdentifierFieldNames($class), explode('-', $id));
return $this->entityManager->getRepository($class)->find($values);
}

Call to a member function getMetadataFactory() on a non-object in ...vendor\bundles\Sonata\DoctrineORMAdminBundle\Model\ModelManager.php on line 49

I am using symfony 2.0.12, and I have implemented the FOSUserBundle, SonataUserBundle, SonataAdminBundle and SonataORMAdminBundle. I can log in and vie the dashboard, but when I try to view a list of users, or add a user through the admin dashboard, I get the error above.

Fatal error: Call to a member function getMetadataFactory() on a non-object in ...vendor\bundles\Sonata\DoctrineORMAdminBundle\Model\ModelManager.php on line 49

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.