【发布时间】:2017-09-25 14:13:54
【问题描述】:
这是我的控制器编辑操作的一部分。方法是PUT。
public function editRentalAction(Request $request, Rental $rental): JsonResponse
{
$rentalManager = $this->get('rental.rental_manager');
$form = $this->createForm(RentalType::class, $rental);
$form->submit(json_decode($request->getContent(), true));
当我尝试从请求中提交一些实体数据(我想要更新的)时,所有其他实体数据都会丢失(设置为null)。我怎么能只更改我发送的这个参数?
请求负载:
{"example_parameter": "example"}
【问题讨论】:
-
你使用的是哪个 symfony 版本?
-
这是 Symfony 3.3
标签: forms symfony symfony-forms