Here is the content of the system.xml file:
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
<system>
<section id="develodesign_productpagerendermsg" showInDefault="1" showInStore="1" showInWebsite="1" sortOrder="10" translate="label">
<label><![CDATA[Product Page Stock Location]]></label>
<tab>catalog</tab>
<resource>Develodesign_General::general</resource>
<group id="company_flag" translate="label" type="text" sortOrder="6" showInDefault="1" showInWebsite="1">
<label>Company Display Settings</label>
<field id="custom_message" translate="label" type="Magento\Config\Block\System\Config\Form\Field\File" sortOrder="1" showInDefault="1" showInWebsite="1" >
<label>Identifier, SKU and Custom Message CSV Mapper</label>
<backend_model>Develodesign\General\Model\Config\Backend\FileUploader</backend_model>
<upload_dir config="system/filesystem/media" scope_info="1">catalog/custom_message</upload_dir>
<comment>CSV Header must be set to Company Id, Product SKU, and Custom Message.</comment>
</field>
<field id="employee_mapper" translate="label" type="Magento\Config\Block\System\Config\Form\Field\File" sortOrder="3" showInDefault="1" showInWebsite="1" >
<label>Employee Name, Sole Code and Boot Code CSV Mapper</label>
<backend_model>Develodesign\General\Model\Config\Backend\FileUploader</backend_model>
<upload_dir config="system/filesystem/media" scope_info="1">catalog/company_employee</upload_dir>
<comment>CSV Header must be set to Employee Name,Sole Code and Boot Code. Allowed file types: csv, xls,text/csv</comment>
</field>
<field id="product_sku" translate="label" type="text" sortOrder="2" showInDefault="1" showInWebsite="1" showInStore="4">
<label>Product SKU</label>
<validate>required-entry</validate>
</field>
</group>
</section>
</system>
</config>
I am using a custom class ....\General\Model\Config\Backend\FileUploader that extends magento Magento\Config\Model\Config\Backend\File Here is the file input greyed out in the admin frontendgreyed out file upload input. Inspecting the element I can see a class 'disabled' being added to the input, removing this class sure fixes the issue, of course, I can add a js file to remove the attribute on document ready, however, I am more interested in why its disabled in the first place.
2 Answers 2
The backend model has to changed to below for files
\Magento\Config\Model\Config\Backend\File
For images the backend model should be
Magento\Config\Model\Config\Backend\Image
And for PDFs
Magento\Config\Model\Config\Backend\Image\Pdf
-
I am using a custom class
Develodesign\General\Model\Config\Backendthan extends theMagento\Config\Model\Config\Backend\FileRaphael– Raphael2020年11月03日 15:05:59 +00:00Commented Nov 3, 2020 at 15:05
If anyone sees this and had a similar issue, it was caused by the configuration value being locked with --lock-env on that environment