Open Fluit opened 5 years ago
There is code to set the path back to the entity,
I think you are setting a value in your post data because you've got a hidden input. This empty value might be overwriting the entity property when you patchEntity with the request data.
I've removed these lines. Even when de posted data doesn't contain the 'scource_dir' field, there is still no value in de saved record.
The problem, I think (when looking a bit deeper) is that in line 87 $entity->get($field)['error'] === UPLOAD_ERR_OK
returns 'false' and even '$entity->get('error') === UPLOAD_ERR_OK' in elseif, so it's why '$this->process()' is skipped.
After passing line 87, directly true is returned (line 102)
So you're having a problem uploading a file to the server. Perhaps this could be a file system permissions issue? move_uploaded_file()
would be a good test to ensure that PHP can write to your file system.
I'm using the Proffer plugin to upload several documents or pictures, linked to a machine.
In DocsTable I added:
Since Machines has a hasMany association, I added in MachinesTable:
In the form is I use this code:
In the controller there is
Problem
Al seems to work fine. The result with al the data is send to my database correctly, except for "source_dir", which stays empty.
debug
After patching the $data in the controller I get as $result:
When I look deeper into your code, I notice that there might be an issue with the method "beforeSave" in "ProfferBehavior.php". Although $entity does have 'scource' as a field it never creates an seed for 'scource_dir' and won't save the file to the server, I think caused by the fact that $entity->get('scource') isn't an array.
How can I solve this?
Thanks in advance.