Closed roland-d closed 2 years ago
Hi, Thanks for reaching out. I believe this might be a Formie plugin issue. Can you please raise an issue here: https://github.com/verbb/formie/issues? I'll also keep investigating from our end too.
Closing due to inactivity. @roland-d please do let us know if there’s more we can do to help, though.
I have been busy with other things but this issue itself is not resolved but as requested I have posted it with Formie as well here: https://github.com/verbb/formie/issues/1130
@roland-d Thanks! Following along over there.
What happened?
Description
We have a Formie form that has 2 FileUpload fields that are required. When we POST this form via GraphQL to Craft the submission is received and Craft starts the process to validate the data. During this validation when it gets to the FileUpload field, the data is removed from the posted submission and replaced with an empty AssetQuery. After that the field is checked if it is empty or not, this confirms it is empty because the AssetQuery is empty.
In the file
/vendor/craftcms/cms/src/fields/Assets.php
line 397 in classnormalizeValue()
the uploaded data is put in$this->_uploadedDataFiles
and then returns an emptycraft\element\db\AssetQuery
. After that the validation starts in the filevendor/yiisoft/yii2/validators/RequiredValidator.php
on line 73 and it fails the check on line 79 because it finds an empty AssetQuery and this fails the required check for the FileUpload field, so the error message is added.The actual error is
{"Resume":["Resume cannot be blank."],"CoverLetter":["Cover Letter cannot be blank."]}
I am not sure what needs to be done but I would think that the AssetQuery should be populated with at least the fileData.
Steps to reproduce
http://site.com/graphql?query=mutation+xxx+{save_Apply_form_Submission(CoverLetter:[{"fileData": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQUA...","filename": "testing.png"}])}
Expected behavior
The expected behavior is that the field is processed as expected because it is not empty
Actual behavior
The submission fails because GraphQL reports the field as being empty
Craft CMS version
Craft Pro 4.2.5.2
PHP version
8.1.0
Operating system and version
Linux 6.0.0-1-MANJARO
Database type and version
MySQL 5.5.5
Image driver and version
GD 8.1.0
Installed plugins and versions