hi i want with sonata to have an item using 'name' label. but not always the same.
i put this in admin class
public function toString($object) {
if (!is_object($object)) {
return '';
}
if (method_exists($object, '__toString') && null !== $object->__toString()) {
return (string) $object;
}
$cname = explode('\\', get_class($object));
return end($cname);
}
but it give always the same name. i want to have the label 'name' of each entity
You need to override the __toString()
magic method in your entity class
public function __toString(){
return $this->name;
}