30

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>

3 Answers 3

56

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
3
  • label does not work
    – Zorox
    Aug 31, 2017 at 10:00
  • any idea on how to make Yes/NO button with green/gray color ? Jun 21, 2018 at 3:55
  • 2
    @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, 2019 at 13:59
19

Looking at the file /lib/internal/Magento/Framework/Data/Form/Element/Factory.php (sources on Github, for Magento 2.2 & 2.3), 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.

5
  • 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, 2018 at 19:55
  • I think you have completed Amit's answer by adding factory file details. Upvoted for this. Apr 25, 2018 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. Apr 25, 2018 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, 2018 at 12:57
  • Can any one can add/explain field types with sorce models, Like yesno has source model Magento/config/model/config/source/yesno Sep 17, 2019 at 14:44
0

Magento 2 docs.

text Standard, single row text field

textarea Text block

select Normal dropdown, may need a custom source_model. Also used for Yes/No selections. See Magento\Search\Model\Adminhtml\System\Config\Source\Engine for an example.

multiselect Like select but multiple options are valid.

button A button that triggers an immediate event. Requires custom front-end model to define the button text and the action. See Magento\ScheduledImportExport\Block\Adminhtml\System\Config\Clean for an example.

obscure A text field with the value encrypted and displayed as ****. Changing the type using “Inspect Element” in the browser does not reveal the value.

password Like obscure except that the hidden value is not encrypted, and forcibly changing the type using “Inspect Element” in the browser does reveal the value.

file Allows a file to be uploaded for processing.

label Displays a label instead of an editable field. Use this type when a field is editable only on specific scopes, for example Store View level only.

time Control to set time using three dropdowns–Hour, minute and second.

allowspecific A multiselect list of specific countries. Requires a source_model such as Magento\Shipping\Model\Config\Source\Allspecificcountries

image Allows an image to be uploaded.

note Allows an informational note to be added to the page. This type requires a frontend_model to render the note.

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.