25

What are available values for field types in etc/system.xml configuration file:

<?xml version="1.0"?>
<config
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
    <system>
        <section id="...">
            <group id="...">
                <field id="..." type="???">
                    ...
                </field>
            </group>
        </section>
    </system>
</config>
44

Magento 2 system configuration provides below fields type.

checkbox,
checkboxes,
column,
date,
editablemultiselect,
editor,
fieldset,
file,
gallery,
hidden,
image,
imagefile,
label,
link,
multiline,
multiselect,
note,
obscure,
password,
radio,
radios,
reset,
select,
submit,
text,
textarea,
time
  • label does not work – Zorox Aug 31 '17 at 10:00
  • any idea on how to make Yes/NO button with green/gray color ? – Zeeshan Khuwaja Jun 21 '18 at 3:55
  • @ZeeshanKhuwaja and future people, this doesn't link to the Q but you want to append <source_model>Magento\Config\Model\Config\Source\Yesno</source_model> to your field – John Mar 13 at 13:59
14

Looking at the file /lib/internal/Magento/Framework/Data/Form/Element/Factory.php (found here on Github, for Magento 2.2-develop), one can find the following default list of elements, as specified by Amit in his answer:

// Factory.php, lines 26-55
protected $_standardTypes = [
    'button',
    'checkbox',
    'checkboxes',
    'column',
    'date',
    'editablemultiselect',
    'editor',
    'fieldset',
    'file',
    'gallery',
    'hidden',
    'image',
    'imagefile',
    'label',
    'link',
    'multiline',
    'multiselect',
    'note',
    'obscure',
    'password',
    'radio',
    'radios',
    'reset',
    'select',
    'submit',
    'text',
    'textarea',
    'time',
];

If Composer was used to install Magento, the data may also be found in /vendor/magento/framework/Data/Form/Element/Factory.php, as mentioned in Mohit's comment below.

  • 2
    My apologies for adding a new answer rather than commenting on Amit's. As of posting this answer I do not have enough reputation to comment on others' answers. – RNanoware Feb 28 '18 at 19:55
  • I think you have completed Amit's answer by adding factory file details. Upvoted for this. – Mohit Kumar Arora Apr 25 '18 at 12:24
  • 3
    But my Magento 2.2.3 does not have such path. I could find Factory.php file at /vendor/magento/framework/Data/Form/Element/Factory.php path. – Mohit Kumar Arora Apr 25 '18 at 12:30
  • 2
    @MohitKumarArora You are correct! I think that the differing file paths have to do with how Magento was installed: cloning from Git seems to use /lib/internal, while Composer is known to create the /vendor folder. I will update the answer accordingly. Thanks! – RNanoware Apr 25 '18 at 12:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.