sonata-project/SonataAdminBundle — Issue #338: Show description for field with custom mapping schema
Author: ardianys
Created: 2011-10-14 09:36:13+00:00
State: open

Another newbie question again here, sorry for bothering you all.

Finally I have made my Sonata Admin Bundle works. But I have a problem where a want to show some data with "Show" link in top menu. I can't displayed some field which have custom mapping schema.

```

class Milestone
{

...
/ **
* @ORM\ManyToOne(targetEntity="Project", inversedBy="milestones")
* @ORM\JoinColumn(name="project_id", referencedColumnName="id")
*/
private $project;

...
}

class Project
{
...
/**
* @ORM\OneToMany(targetEntity="Milestone", mappedBy="project")
*/
private $milestones;
....
}

```

When I click "Show" menu for one row of my milestone data, there is no "Project" field displayed.

Then I digging inside this bundle and found some code under

```
public_html/symfony/vendor/bundles/Sonata/AdminBundle/Builder/ORM/ShowBuilder.php
```

the code is in line 49

```
switch($fieldDescription->getMappingType()) {
case ClassMetadataInfo::MANY_TO_ONE:
case ClassMetadataInfo::MANY_TO_MANY:
case ClassMetadataInfo::ONE_TO_MANY:
case ClassMetadataInfo::ONE_TO_ONE:
// todo
return;
default:
$list->add($fieldDescription);
}
```

there is TODO comment, and when I add some code so this code become

```
switch($fieldDescription->getMappingType()) {
case ClassMetadataInfo::MANY_TO_ONE:
case ClassMetadataInfo::MANY_TO_MANY:
case ClassMetadataInfo::ONE_TO_MANY:
case ClassMetadataInfo::ONE_TO_ONE:
// todo
$list->add($fieldDescription);
return;
default:
$list->add($fieldDescription);
}
```

I got my project name displayed in Show page. Is it correct for adding this code to core of this bundle ?

I really new in this S2 world and need some advices,

Regards.