我正在開發一個已經開始的項目,當我在實體中添加一個屬性時,我得到了這個異常,這個屬性是一個簡單的列,從另一個實體(personnal)獲取它的值,它是一個多選擇值,新頁面的呈現沒有問題,但是當我提交時,我得到這個例外,我添加的字段是這樣的:Symfony 2:ContextErrorException:注意:serialize():「url」作爲__sleep()的成員變量返回,但不存在
/**
* @var array
*
* @ORM\Column(name="responsable",type="array", nullable=true)
*
*/
private $responsable;
/**
* Add responsable
*
* @param $responsable
* @return Actionreclamation
*/
public function addResponsable($responsable)
{
if (!in_array($responsable, $this->responsable, true)) {
$this->responsable[] = $responsable;
}
return $this;
}
/**
* Remove responsable
*
* @param $responsable
*/
public function removeResponsable($responsable)
{
// $this->responsable->removeElement($responsable);
if (false !== $key = array_search($responsable, $this->responsable, true)) {
unset($this->responsable[$key]);
$this->responsable = array_values($this->responsable);
}
return $this;
}
/**
* Get responsable
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getResponsable()
{
return $this->responsable;
}
/**
* Set responsable
*
* @param array $responsable
* @return Actionreclamation
*/
public function setResponsable($responsable)
{
$this->responsable = $responsable;
return $this;
}
和形式類型內:
->add('responsable', 'entity', array(
'class' => 'UserUserBundle:Personnel',
'property' => 'nompersonnel',
'multiple' => true))
視圖內:
<div class="form-group">
<label class="col-md-3 control-label">Responsable</label>
<div class="col-md-6">
<div class="input-icon right">
<i class="fa"></i>
{{ form_widget(form.responsable) }}
</div>
<span class="help-block">{{ form_errors(form.responsable) }}</span>
</div>
</div>
plz我需要幫助!
的例外是:
in C:\wamp\www\GESTIBAT0.1\vendor\doctrine\dbal\lib\Doctrine\DBAL\Types\ArrayType.php line 38
at ErrorHandler->handle('8', 'serialize(): "url" returned as member variable from __sleep() but does not exist', 'C:\wamp\www\GESTIBAT0.1\vendor\doctrine\dbal\lib\Doctrine\DBAL\Types\ArrayType.php', '38', array('value' => array(object(Personnel), object(Personnel)), 'platform' => object(MySqlPlatform)))
at serialize(array(object(Personnel), object(Personnel))) in C:\wamp\www\GESTIBAT0.1\vendor\doctrine\dbal\lib\Doctrine\DBAL\Types\ArrayType.php line 38
at ArrayType->convertToDatabaseValue(array(object(Personnel), object(Personnel)), object(MySqlPlatform)) in C:\wamp\www\GESTIBAT0.1\vendor\doctrine\dbal\lib\Doctrine\DBAL\Statement.php line 98
at Statement->bindValue('6', array(object(Personnel), object(Personnel)), 'array') in C:\wamp\www\GESTIBAT0.1\vendor\doctrine\orm\lib\Doctrine\ORM\Persisters\BasicEntityPersister.php line 273
at BasicEntityPersister->executeInserts() in C:\wamp\www\GESTIBAT0.1\vendor\doctrine\orm\lib\Doctrine\ORM\UnitOfWork.php line 929
at UnitOfWork->executeInserts(object(ClassMetadata)) in C:\wamp\www\GESTIBAT0.1\vendor\doctrine\orm\lib\Doctrine\ORM\UnitOfWork.php line 318
at UnitOfWork->commit(null) in C:\wamp\www\GESTIBAT0.1\vendor\doctrine\orm\lib\Doctrine\ORM\EntityManager.php line 355
at EntityManager->flush() in C:\wamp\www\GESTIBAT0.1\src\Client\ClientBundle\Controller\ActionreclamationController.php line 56
at ActionreclamationController->createAction(object(Request))
at call_user_func_array(array(object(ActionreclamationController), 'createAction'), array(object(Request))) in C:\wamp\www\GESTIBAT0.1\app\bootstrap.php.cache line 2843
at HttpKernel->handleRaw(object(Request), '1') in C:\wamp\www\GESTIBAT0.1\app\bootstrap.php.cache line 2817
at HttpKernel->handle(object(Request), '1', true) in C:\wamp\www\GESTIBAT0.1\app\bootstrap.php.cache line 2946
at ContainerAwareHttpKernel->handle(object(Request), '1', true) in C:\wamp\www\GESTIBAT0.1\app\bootstrap.php.cache line 2248
at Kernel->handle(object(Request)) in C:\wamp\www\GESTIBAT0.1\web\app_dev.php line 28
thanx提前!
「編輯」 主實體名爲「ActionReclamation」,它有一個名爲「responsable」的字段(與數據庫中的varchar無關的簡單列),該字段的值是從另一個名爲「Personnel」的實體返回的,在視圖中顯示「人員」實體的值,我可以選擇多個值
我解釋得好嗎? thanx求助
在其他字段中插入值時,我有一個apload字段,如果只是我把光標放在上傳字段並提交後,我得到了這個異常,如果我不碰它,我得到了相同的異常但另一個字段的名稱是「matricule」 – krachleur 2014-09-24 09:47:02
ContextErrorException:注意:serialize():「matriculepersonnel」作爲__sleep()的成員變量返回,但在C:\ wa中不存在mp \ www \ GESTIBAT0.1 \ vendor \ doctrine \ dbal \ lib \ Doctrine \ DBAL \ Types \ ArrayType.php第38行 – krachleur 2014-09-24 09:47:41
你能編輯你的文章,爲你的實體放置你的Doctrine映射信息嗎? – 2014-09-24 09:49:26