I have created a form by exending Magento\Backend\Block\Widget\Form\Generic
class in my class.
I am adding a field using $fieldset->addField()
to my form for which I need to add "Use Default Value" checkbox field like below screenshot.
With dataProvider
class in ui_component
form, this is done by setting
'arguments' => [
'data' => [
'config' => [
'dataType' => 'text',
'formElement' => 'input',
'componentType' => 'field',
'label' => 'Field',
'validation' => [
'validate-digits' => true,
],
/*
* Below line of code adds the checkbox which
* Enable/Disable input field when checked
*/
'service' => [
'template' => 'ui/form/element/helper/service',
],
],
],
]
Any idea on how to set it for my addField
function? I have tried it adding as a config parameter but its not working.
$fieldset->addField(
'field',
'text',
[
'name' => 'field',
'label' => __('Field'),
'title' => __('Field'),
'required' => true,
'service' => [
'template' => 'ui/form/element/helper/service',
]
]
);