In magento 2 What I need to use instead of "after_element_html". In magento2 form structure is in xml format, then how do I give note for a particular field in form ? Please provide me a solution
2 Answers
This is something if you want to add after the field element you are adding in admin form
You can added whatever you want html, javascript code, css
-
I need to set dynamic data for a particular field in admin form in magento 2– JaisaCommented Jan 17, 2018 at 13:11
$form = $this->_formFactory->create();
$fieldset = $form->addFieldset('base_fieldset', ['legend' => __('Widget')]);
$fieldset->addField(
'select_widget_type',
'select',
[
'label' => __('Widget Type'),
'title' => __('Widget Type'),
'name' => 'widget_type',
'required' => true,
'onchange' => "wWidget.validateField()",
'options' => $this->_getWidgetSelectOptions(),
'after_element_html' => $this->_getWidgetSelectAfterHtml()
]
);
$form->setUseContainer(true);
$form->setId('widget_options_form');
$form->setMethod('post');
$form->setAction($this->getUrl('adminhtml/*/buildWidget'));
$this->setForm($form);