sonata-project/SonataDoctrineORMAdminBundle — Issue #35: oneToMany - addComments VS addComment
Author: giorrrgio
Created: 2012-01-19 19:55:52+00:00
State: open

I have defined two entities, Article and Comment:

```php

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;

```

```php

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:

```php

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()
;
}

```

```php

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, non comment is saved.

Any clue?