asprin
Active member
Hi experts,
In my entity's
This is throwing the
This resulted in
So I'm now out of ideas on how to go about achieving this.
(a) I cannot use the
(b) If I use
Any suggestions?
In my entity's
_postSave
function, my use case is to update a column belonging to the same entity. So I'm using the following code:
PHP:
protected function _postSave()
{
// sys_id is primary key column on the entity
$upload = $this->app()->request()->getFile('upload', false, false);
$filename = 'myfile_'.$this->sys_id.'.'.$upload->getExtension(); // so this becomes something like myfile_123.png
$this->path_to_file = $filename;
}
This is throwing the
forceSet
error. So I looked at Xenforo's code and found some samples and tried with the following:
PHP:
// sys_id is primary key column on the entity
$upload = $this->app()->request()->getFile('upload', false, false);
$filename = 'myfile_'.$this->sys_id.'.'.$upload->getExtension();
$this->set('path_to_file', $filename, ['forceSet' => true]);
$this->save();
This resulted in
Duplicate entry 'xxx' for key 'PRIMARY'
error message.So I'm now out of ideas on how to go about achieving this.
(a) I cannot use the
_preSave()
function because I need the $this->sys_id
value which will not be available in presave.(b) If I use
_postSave()
function, I've been unsuccessful at getting it to work.Any suggestions?
Last edited: