Source for file Radio.php
Documentation is available at Radio.php
* A Framework for Creating and Using Complex Web Elements
* The purpose of this framework is to provide a library of high-level objects
* to facilitate common HTML coding tasks, such as menus, tables, and forms.
* The intent is to reduce repetitive HTML coding as much as possible, replacing
* it with a combination of configuration files and style sheets with
* standardized naming conventions.
* This framework is built on and requires the
* {@link http://framework.zend.com/ Zend Framework}.
* @author Lyle Frost <lfrost@cnz.com>
* @copyright Copyright (c) 2006-2007 Citadel Network <{@link http://www.citadelnetwork.com/}>
* @license http://www.citadelnetwork.com/license/cnzframework New BSD License
* @version $Id: Radio.php 27 2007-07-19 18:47:54Z lfrost $
Zend_Loader::loadClass('Cnz_Html_Form_Item');
* This class automates the creation and display of a radio button group.
* item.contact_method.label = "Contact Method"
* item.contact_method.type = radio
* item.contact_method.list = "
* item.contact_method.initial = phone
* If only a single field is specified for a list item, that is used for both
* the label and the value for that item.
* To use images, specify three fields <kbd>value:altText:filepath</kbd>. If the
* filepath is relative, it is taken to be relative to the local image directory.
/** Associative array value => label */
private $itemArray = NULL;
/* Methods ===========================================================*/
* br Flag to enable br tag between radio buttons
* @param array $options Options
* @param Zend_Config $config Configuration
public function __construct(array $options = array(), Zend_Config $config = NULL)
* @param string $style Value for outermost style attribute
public function display($style = NULL)
echo $indent, '<div class = "', $this->genStyles('label'), '">';
echo $indent, '<div class = "', $this->genStyles('field'), '">', "\n";
foreach ($this->itemArray as $value => $label)
echo $indent, $is, '<input';
echo ' checked = "checked"';
echo ' id = "', $this->genId($number), '" name = "', $this->name, '" type = "radio" value = "', $value, '"/>', "\n";
echo $indent, $is, '<label for = "', $this->genId($number), '">';
echo '<img alt = "[', $label, ']" class = "', $this->genStyles(), '" src = "';
if (substr($src, 0, 1) != '/') echo 'image/';
if ($this->br) echo '<br/>';
echo $indent, '</div>', "\n";
|