sonata admin is using to string i think. and when you have a new document without a name the tostring would fail. as it must return string and only string. hence also the (string) cast, in case somebody manages to put something not a string into the name field.