I've created two dropdowns field in the system.xml , both of them have the same options, except that one has an extra option: None. This is the xml:
<field id="printing_option" translate="label" type="select" showInDefault="1" showInWebsite="0" showInStore="0" sortOrder="4"> <label>Printing option</label> <source_model>Vendor\Module\Model\Config\Source\PrintingOption</source_model> </field> <field id="printing_option_2" translate="label" type="select" showInDefault="1" showInWebsite="0" showInStore="0" sortOrder="4"> <label>Printing option 2</label> <source_model>Vendor\Module\Model\Config\Source\PrintingOption</source_model> </field> and in my Vendor\Module\Model\Config\Source\PrintingOption I have:
namespace Vendor\Module\Model\Config\Source; use Magento\Framework\Data\OptionSourceInterface; class PrintingOption implements OptionSourceInterface { /** * Printing options: automatic or manual * * @return array */ public function toOptionArray() : array { return [ // I want to add the none option for my second field ['value' => 2, 'label' => __('NONE')], ['value' => 1, 'label' => __('Automatic')], ['value' => 0, 'label' => __('Manual')] ]; } } I want to add the NONE option only for my second dropdown. Is there a way to do this, instead of creating a new source model ? and to avoid duplicate codes ?
Thnx