[英]Symfony Form Collection won't remove element
表格类型
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
......
->add('menores', 'collection', array(
'type' => new CotizacionMenorType(),
'allow_add' => true,
'allow_delete' => true,
'by_reference' => false,
'required' => false
))
......
;
}
调节器
public function editarAction(Cotizacion $cotizacion, Request $request)
{
$pageData['accion'] = 'Editar';
$objForm = $this->createForm(new EditarCotizacionType(), $cotizacion);
$objForm->handleRequest($request);
if ($objForm->isValid()) {
echo '<pre>';
echo \Doctrine\Common\Util\Debug::dump($cotizacion->getMenores());
die('</pre>');
.............
}
.......
}
当我渲染表单并删除DOM 1元素时,我提交表单和元素仍然在coleccion中。当我打印de $cotizacion->getMenores()
,删除的元素仍然存在
谢谢
在您的关系注释中,请确保已设置orphanRemoval。
@ORM\OneToMany(targetEntity="Image", cascade={"persist"}, orphanRemoval=true)
此错误是由版本2.3.10 https://github.com/symfony/symfony/issues/10256中的错误引起的,感谢A6 Software提供的帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.