Reference - Form arguments

A Loki_AdminComponents is a form that is defined within the XML layout:

<block name="yireo-training.example-admin.form" template="Loki_AdminComponents::form.phtml">
    <arguments>
        <argument name="foo" xsi:type="string">bar</argument>
    </arguments>
</block>

XML layout base arguments

A form block can be supplied with the following XML arguments:

provider (string or object, required)

A class or classname supported by available provider handlers, like collections, repositories or array providers.

provider_handler (string)

A string pointing to the provider handler. Often this is not needed. But it can be used if the automatic detection fails.

resource_model (string or object)

By default, a repository handler is unable to retrieve column-information from the repository. By providing the classname for the resource_model, you can help the repository handler determine things automatically. This, or you need to supply the columns in a different way.

factory (string or object)

A class or classname to instantiate a model object when needed. This is (definitely) needed when creating new items. However, the core logic tries its best (via PHP Reflection) to detect the factory class automatically. This argument is only needed when this autodetection fails../bin

fields (array)

By default, the form tries to display all fields from the underlying table, but this might include fields that you don't want to display. By adding the fields property, you can add your own fields or overriding existing fields.

index_url (string)

If the grid URL is not */*/grid, then it needs to be changed with this argument.

item_convertor (object)

An instance of Loki\AdminComponents\Form\ItemConvertorInterface to transform the item data before sending it to the form.

XML layout field arguments

label (string)

By default, the field label is extracted by converting the field name (example_item_name) into readable text (pascal-case with dashes replaced with spaces). The label can be customized with this argument.

code (string)

This sets the name of the HTML form field and some other things. Usually, it should not be changed via XML layout, but simply is the same as the actual database column name.

sort_order (number)

Each field is supported by default in the order that they are detected - commonly, the order of the columns in the database structure. You can change this with this argument.

field_type (string)

The default field_type is text, but you can customize this by setting the field_type.

required (boolean)

Boolean to indicate that the field is required.

placeholder (string)

Placeholder text.

field_attributes (array)

An associative array of attribute names and values to use as HTML attributes of the HTML field element. This can be anything. For instance, you can set the number of rows in an textarea. Or you can set a specific autocomplete value.

label_attributes (array)

An associative array of attribute names and values to use as HTML attributes of the HTML label element.

multiple (boolean)

When the field type is select, this allows you to create a multiple select.

size (boolean)

This allows you to set the HTML attribute size with select fields.

options (object)

When the field type allows for multiple options (like with select or switch), this class supplies the options. The class needs to be an instance of Magento\Framework\Data\OptionSourceInterface.

empty_option (string)

When the field type is select, this allows you to add an additional empty option.

Example configuration of fields

<block name="yireo-training.example-admin.form">
    <arguments>
        <argument name="fields" xsi:type="array">
            <item name="id" xsi:type="array">
                <item name="sort_order" xsi:type="number">0</item>
            </item>
            <item name="name" xsi:type="array">
                <item name="sort_order" xsi:type="number">1</item>
                <item name="label" xsi:type="string">Item Name</item>
            </item>
            <item name="description" xsi:type="array">
                <item name="sort_order" xsi:type="number">2</item>
            </item>
        </argument>
    </arguments>
</block>
Last modified: September 1, 2025