-3
誰でもこの問題を解決する手助けはできますか?私はなぜ知らないが、私はこの例外を取得:キャッチ可能な致命的なエラー:AppBundle Entity Jobクラスのオブジェクトを文字列に変換できませんでした
Catchable Fatal Error: Object of class AppBundle\Entity\Job could not be converted to string
私のエンティティカテゴリ:
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Category
*
* @ORM\Table(name="category")
* @ORM\Entity(repositoryClass="AppBundle\Repository\CategoryRepository")
*/
class Category
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="label", type="string", length=255)
*/
private $label;
/**
* @var string
*@ORM\ManyToMany(targetEntity="Job", mappedBy="categories", cascade={"persist", "merge"})
*/
private $jobs ;
/**
* Constructor
*/
public function __construct()
{
$this->jobs = new \Doctrine\Common\Collections\ArrayCollection();
}
/**
* Get id
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Set label
*
* @param string $label
*
* @return Category
*/
public function setLabel($label)
{
$this->label = $label;
return $this;
}
/**
* Get label
*
* @return string
*/
public function getLabel()
{
return $this->label;
}
/**
* Add job
*
* @param \AppBundle\Entity\Job $job
*
* @return Category
*/
public function addJob(\AppBundle\Entity\Job $job)
{
$this->jobs[] = $job;
return $this;
}
/**
* Remove job
*
* @param \AppBundle\Entity\Job $job
*/
public function removeJob(\AppBundle\Entity\Job $job)
{
$this->jobs->removeElement($job);
}
/**
* Get jobs
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getJobs()
{
return $this->jobs;
}
}
エンティティの設定(easyadmin)、私はカスタムにいくつかのフィールドを選択します。
easy_admin:
design:
entities:
Category:
class: AppBundle\Entity\Category
スクリーンショットでバグやその意味を正確に説明していますか?
を、このメソッドを追加 – Frameman
これは、オブジェクトを文字列にキャストしようとするときに使用される魔法の方法です。 http://php.net/manual/en/language.oop5.magic.php#object.tostring –
ああ、ありがとう..私はその情報を忘れてしまった – Frameman