1

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();

1 Answer 1

3

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.