Unknown type "upload.file" thrown by Cake\Database\TypeFactory when submiting form
mortinp opened this issue · 2 comments
Hello there!
I am using the cake 4.x branch of the plugin and started to use it.
I am trying to submit a form with an image. I am using this to create the field, which seems good:
$this->Form->control('photo', ['type'=>'file']);
When I submit the form, I am getting an error from Cake\Database\TypeFactory saying:
Unknown type "upload.file"
The error is thrown when TypeFactory is trying to build the columnType and marshal the value.
Because the type "upload.file" does not exist in TypeFactory::$_builtTypes or in TypeFactory::$_types, it throws this error:
throw new InvalidArgumentException(sprintf('Unknown type "%s"', $name));
Where $name's vale is: "upload.file".
Not sure how I can make this "upload.file" type work properly. Am I missing some php extension or something?
Thanks for the help!
Found the problem! I wasn't setting the plugin's bootstrap() function to true so that it could map the type "upload.file" to Josegonzalez\Upload\Database\Type\FileType, like this:
$this->addPlugin('Josegonzalez/Upload', ['bootstrap'=>true]);
Now I'm getting the error discussed on issue #535
I am closing this issue now.
A NOTE
Issue #535 definitely looks like an error, since the returned value of $entity->get($field) is ALWAYS a string and not a Psr\Http\Message\UploadedFileInterface.
Running a plugin's bootstrap hook is enabled by default and explicitly enabling it shouldn't be necessary.