Reputation: 1183
I know this question has been asked severally SonataAdmin: replace ID in breadcrumbs and toString method for SonataAdminBundle Listing in Symfony2 but none of the solutions offered worked for me.
Here's what i tried having in my entity
public function __toString()
{
return $this->getFoo() ? : '-';
}
public function __toString()
{
return ($this->getFoo()) ? : '';
}
public function __toString()
{
return (string)$this->getFoo();
}
public function __toString()
{
$this->getFoo() ? : 'n/a';
}
I still get IDs in both editing and create views. Anything else I might have forgotten? Using symfony 2.4 and latest version of Sonata Admin Bundle
Upvotes: 0
Views: 256
Reputation: 1654
Change your entity class to this:
<?php
namespace ACME\MyBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Pipeline
*/
class Pipeline
{
.... code goes here ....
....
public function __toString()
{
return (string) $this->getTitle() ? $this->getTitle() : 'New';
}
}
Upvotes: 1