首页 > 解决方案 > CakePHP 3 提交后从控制器中清除选定的输入值

问题描述

在 CakePHP 3 中,如何在提交后从控制器中只清除一个选定的输入值?我不想清除所有输入值,只清除一个输入。

标签: cakephp

解决方案


在您的控制器中:

$data = $this->getRequest()->getData();
unset($data['fieldname']); // unset / remove field from array 

或为该字段设置空值

$this->getRequest()->withData('fieldname', null);

推荐阅读