在 abeforeMarshall()
中,我在我的实体中创建了一个附加字段。在我的控制器中,debug($myEntity)
在将数据分配给视图之前,我看到了我的字段。我什至创建了一个像下面这样的吸气剂:
protected function _getTmpImage() {
if (isset($this->_properties['tmp_image'])) {
debug($this->_properties['tmp_image']);
return $this->_properties['tmp_image'];
} else {
return null;
}
}
在我看来,我看到了相应的debug()
显示。
但是下面一行:
<?= $this->Form->hidden('agpoi_images.'.$key.'.tmp_image'); ?>
拼命创建以下html代码:
<input name="agpoi_images[0][tmp_image]" class="form-control" value="" type="hidden">
你能告诉我为什么吗?
PS:我也尝试在我的实体类中添加以下语句,即使我认为根据文档我不必这样做
class MyEntity extends Entity
{
protected $_virtual = ['tmp_image'];
}