Magento 2: How to set radio input value using ui form
Finally i got the answer
<field name="gender">
<argument name="data" xsi:type="array">
<item name="options" xsi:type="object">[vendor]\[module]\Model\Config\Source\Gender</item>
<item name="config" xsi:type="array">
<item name="sortOrder" xsi:type="number">20</item>
<item name="dataType" xsi:type="string">text</item>
<item name="formElement" xsi:type="string">radioset</item>
<item name="label" xsi:type="string" translate="true">Gender</item>
<item name="source" xsi:type="string">category</item>
<item name="validation" xsi:type="array">
<item name="required-entry" xsi:type="boolean">true</item>
</item>
</item>
</argument>
</field>
Create > [vendor]/[module]/Model/Config/Source/Gender.php
namespace [Vendor]\[module]\Model\Config\Source;
use Magento\Framework\Option\ArrayInterface;
class Gender implements ArrayInterface
{
/**
* @return array
*/
public function toOptionArray()
{
$options = [
0 => [
'label' => 'Male',
'value' => 'male'
],
1 => [
'label' => 'Female',
'value' => 'female'
],
];
return $options;
}
}
Use this fieldset :
<item name="formElement" xsi:type="string">radioset</item>