Custom Field Type
In certain cases you will need to create a custom field type to achieve specific input abilities.
Let's create grid input field type for custom set of items.
#
File structure#
registration.phpThis file registers module in Magento system. Without this file the module is not visible.
#
etc/module.xmlIn this file we holds basic description of our module. We need to set the sequence so the module is loaded after the main WebForms extension.
#
etc/webforms.xmlThis is used to register new field type.
#
etc/di.xmlWe define custom block class for our field model.
#
Block/Form/Element/Field/Type/CustomField.phpHere we define our frontend block.
#
Model/Field/Type/CustomField.phpEach field type depends on the main model which should extend the AbstractField class.
#
Ui/Field/Type/CustomField.phpUi classes hold admin ui configurations like result column and extra parameters inputs. Each field type depends on the main model which should extend the AbstractField class.
#
frontend/temlpates/form/element/field/type/custom-field.phtmlThe frontend template referenced in the CustomField block. The template is calling the frontend JavaScript component.
#
frontend/web/js/custom-field.jsThe frontend JavaScript component which was referenced in the custom-field.phtml template.
#
frontend/web/template/custom-field.htmlThe template for the JavaScript component which was referenced in the custom-field.phtml template.
After the module is ready, please run following console commands:
Feel free to modify this extension, experiment and add required customization to WebForms.
You can download sources here.