Generate radio grpoup with JHTML
Joomla provides very useful class called JHTML that can be used to produce different HTML elements saving us time and code. The Joomla team has provided a very useful class loader method “_()” in which we can pass string for an element we would like to generate. Example of elements are:
That is not the full extended list of options but that will give you a good idea of what JHTML could do for you. For now we will focus on the “select.option” and “select.radiolist” elements. Lets see it in action:
[cc lang=”php”]$option = JHTML::_( ‘select.option’, ‘left’, ‘Left’ );
$option = JHTML::_( ‘select.option’, ‘right’, ‘Right’ );
$select JHTML::_(‘select.radiolist’, $option, ‘align’, ‘class=”inputbox” ‘, ‘value’, ‘text’, ‘left’, ‘align’ );
This class is very useful especially if you have to create Yes/No radio buttons or group of buttons in the View of the website. This example is valid for Joomla v1.5 in v1.6 there has been some changes which will be covered shortly.