Form field types
By default, the field type of form field is text, resulting in an HTML <input> element. You can override this type by setting a new field_type in the system.
<?xml version="1.0"?> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:View/Layout:etc/page_configuration.xsd"> <update handle="loki_admin_components_form"/> <body> <referenceContainer name="content"> <block name="yireo-training.example-admin.form" template="Loki_AdminComponents::form.phtml"> <arguments> <argument name="fields" xsi:type="array"> <item name="description" xsi:type="array"> <item name="field_type" xsi:type="string">textarea</item> </item> </argument> </arguments> </block> </referenceContainer> </body> </page>
Existing field types
By default, the following field types are present:
view(to only display the text value)texttextareadatedatetimenumberselectswitchfrom_toproduct_id
Adding a custom field type
New field types can be created by adding a DI type (etc/di.xml):
<?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> <type name="Loki\AdminComponents\Form\Field\FieldTypeProvider"> <arguments> <argument name="fieldTypes" xsi:type="array"> <item name="foobar" xsi:type="object">YireoTraining\LokiAdmin\Form\Field\FieldType\Foobar</item> </argument> </arguments> </type> </config>
The new class needs to implement the interface Loki\AdminComponents\Form\Field\FieldTypeInterface:
<?php declare(strict_types=1); namespace YireoTraining\ExampleAdmin\Form\Field\FieldType; use Loki\AdminComponents\Form\Field\FieldTypeInterface; class Foobar implements FieldTypeInterface { public function getTemplate(): string { return 'YireoTraining_ExampleAdmin::form/field_type/foobar.phtml'; } }
Last modified: May 13, 2026