Forums

Update file field

cesarvelame 12 Jan, 2021
Hi, I have this file field "arquivo" in a CC6 form and works very well to create new records, but the edit works wrong. The edit form empty the file field record when is not filled.

I tried this code in a function before saving data with no success:
if(empty($this->data["arquivo"])){
unset($this->data["arquivo"]);
}

I tried this too:
$new_data = $this->data;
if(empty($this->data["arquivo"])){
unset($new_data["arquivo"]);
}
$this->set("new", $new_data);
{var:new} as the data provider, but no success.

Can anyone send a tip?

Thanks
cesarvelame 12 Jan, 2021
Answer
Solved:
$this->data["doc"]["arquivo"] = $this->data["arquivo"];
if(empty($this->data["doc"]["arquivo"])){
unset($this->data["doc"]["arquivo"]);
}
You need to login to be able to post a reply.