Magento2 – How to Add Radio Option in Magento 2

adminformmagento-2.0magento2

I am trying to add radio option but showing single radio without any label

$fieldset->addField(
            'test',
            'radio',
            [
                'label' => __('test'),
                'title' => __('test'),
                'name' => 'test',
                'required' => true,
                'values' => array(
                            array('value'=>'1','label'=>'Radio1'),
                            array('value'=>'2','label'=>'Radio2'),
                            array('value'=>'3','label'=>'Radio3'),
                       ),
                'disabled' => $isDisabled
            ]
        );

Best Answer

change type from radio to radios

$fieldset->addField(
            'test',
            'radios',
            [
                'label' => __('test'),
                'title' => __('test'),
                'name' => 'test',
                'required' => true,
                'values' => array(
                            array('value'=>'1','label'=>'Radio1'),
                            array('value'=>'2','label'=>'Radio2'),
                            array('value'=>'3','label'=>'Radio3'),
                       ),
                'disabled' => $isDisabled
            ]
        );

for more types you can look in to namespace Magento\Framework\Data\Form\Element