Closed
Description
Preconditions (*)
- Magento CE version 2.2.7
- Create custom attribute programmatically, which is to be added to the 'customer eav attribute e.g.:
$customerSetup->addAttribute(\Magento\Customer\Model\Customer::ENTITY, "customerprofile", array(
"type" => "varchar",
"backend" => "",
"label" => "Customerprofile",
"input" => "file",
"source" => "",
"visible" => true,
"required" => false,
"default" => "",
"frontend" => "",
"unique" => false,
"note" => ""
));
$customerdoc = $customerSetup->getAttribute(\Magento\Customer\Model\Customer::ENTITY, "customerdoc");
$customerdoc = $customerSetup->getEavConfig()->getAttribute(\Magento\Customer\Model\Customer::ENTITY, 'customerdoc');
$used_in_forms[] = "adminhtml_customer";
$used_in_forms[] = "checkout_register";
$used_in_forms[] = "customer_account_create";
$used_in_forms[] = "customer_account_edit";
$used_in_forms[] = "adminhtml_checkout";
$customerdoc->setData("used_in_forms", $used_in_forms)
->setData("is_used_for_customer_segment", true)
->setData("is_system", 0)
->setData("is_user_defined", 1)
->setData("is_visible", 1)
->setData("sort_order", 100);
$customerdoc->save();
Steps to reproduce (*)
- Go to the registration form. you will show Customer profile attribute as a file. when user upload an image error message show "Customer profile is not a valid file".
Expected result (*)
- file is valid so data want to save.
Actual result (*)
- is not a valid file message on the frontend and backend.
Issue In this file (*)
-
An issue in the if a condition "Magento\Eav\Model\Attribute\Data\File"
protected function _validateByRules($value)
{
if (!empty($value['tmp_name']) && !is_uploaded_file($value['tmp_name'])) {
return [__('"%1" is not a valid file.', $label)];
}
return [];
}
Acctually Image first of upload in temp folder then after move into accordinglly.
according to the condition if a file exists in temp folder it's throw error.
Resolve the issue(*)
protected function _validateByRules($value)
{
if (empty($value['tmp_name']) && is_uploaded_file($value['tmp_name'])) {
return [__('"%1" is not a valid file.', $label)];
}
return [];
}
Metadata
Metadata
Assignees
Labels
The issue has been fixed in 2.2 release lineThe issue has been fixed in 2.3 release lineGate 2 Passed. Manual verification of the issue description passedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedGate 1 Passed. Automatic verification of issue format passedGate 4. Acknowledged. Issue is added to backlog and ready for developmentThe issue has been reproduced on latest 2.3 release