I need to add radio option in one of my custom form of admin. Form is created by UI component. I use below code to create a radio options and it gets appear too but the problem which I face is
1) Name of the element is not appearing the one which I have given.
2) Label is not showing.
UI component code
<field name="radio_name"> <argument name="data" xsi:type="array"> <item name="options" xsi:type="object">Compony\Test\Model\Source\Type</item> <item name="config" xsi:type="array"> <item name="label" xsi:type="string" translate="true">Radio Label</item> <item name="visible" xsi:type="boolean">true</item> <item name="dataType" xsi:type="string">text</item> <item name="formElement" xsi:type="string">radioset</item> </item> <item name="validation" xsi:type="array"> <item name="required-entry" xsi:type="boolean">true</item> </item> </argument> </field>
Source Model
namespace Compony\Test\Model\Source; use Magento\Framework\Option\ArrayInterface; class Type implements ArrayInterface { public function toOptionArray() { $ options = [ 0 => [ 'label' => __('A'), 'value' => 1 ], 1 => [ 'label' => __('B'), 'value' => 2 ], ]; return $ options; } }
Result