Answers.Body: <p>Its pretty simple to add it as a group of radio button, adding below snippet on how you can add (not tested)</p>
  
  <pre><code>    $choice = [];
      forach ($data as $id =&gt; $value) {
        $choice[$value[0]] = $form-&gt;createElement('radio', NULL, '', $value[1], $value[0]);
      }
      $form-&gt;addGroup($choice, 'element_name_of_radio_button', ts('label of radio button'));
  </code></pre>
  
  <p>HTH</p>
  
  <p>Pradeep</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-02-01T10:14:40.963Z
Answers.LastActivityDate: 2019-02-01T10:14:40.963Z
Answers.UserDisplayName: Pradeep Nayak
Body: <p>Showing data in the form of radio buttons.</p>
  
  <blockquote>
    <p>Data</p>
  </blockquote>
  
  <pre><code>$data[$count++] = array(dao-&gt;id,dao-&gt;names);
  </code></pre>
  
  <p>Above code return an array of id and names which is retrieved from database.<br>
  I want to put this data as radio button.
  How to do that using buildQuickForm();</p>
  
Tags: <extension><forms>
Title: How to add a radio button with the help of buildQuickForm()
ThreadText: # How to add a radio button with the help of buildQuickForm()
  
  (Asked by: username_0 on 2019-02-01)
  
  Showing data in the form of radio buttons.
  
  Data
  
  $data[$count++] = array(dao->id,dao->names);
  
  Above code return an array of id and names which is retrieved from database.
  I want to put this data as radio button.
  How to do that using buildQuickForm();
  
  **Tags:** extension, forms
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2019-02-01. Score: 2
  
  Its pretty simple to add it as a group of radio button, adding below snippet on how you can add (not tested)
      $choice = [];
      forach ($data as $id => $value) {
        $choice[$value[0]] = $form->createElement('radio', NULL, '', $value[1], $value[0]);
      }
      $form->addGroup($choice, 'element_name_of_radio_button', ts('label of radio button'));
  
  HTH
  Pradeep
  
  
  ---
  
  