With DOMDocument, I can create one radio input like this:
$html = new DOMDocument;
$radio = $html->createElement ( 'input' );
$radio->setAttribute ( 'type', 'radio' );
$radio->setAttribute ( 'name', 'test-ratio' );
$fieldset->appendChild ( $radio);
This will create a single radio input. When I have a list of choice, should I repeat the above code to create a list of radio input, or, is there a better way?
You don’t need to create a new DomDocument to create radio buttons, just reuse the one you already have.
Also you can make one radio input and use cloneNode make copies of them.