Hi all. Took my first attempt at building a custom helper. It outputs a series of radio buttons in a UL list, with each radio having an associated LABEL.
<code> function radio($fieldName, $options, $inbetween = null, $htmlAttributes = array(), $return = false) { $this->setFormTag($fieldName); $value = isset($htmlAttributes['value']) ? $htmlAttributes['value'] : $this->tagValue($fieldName); $out = array(); foreach($options as $optValue => $optTitle) { $optionsHere = array('value' => $optValue); $optValue == $value ? $optionsHere['checked'] = 'checked' : null; $parsedOptions = $this->parseHtmlOptions(array_merge($htmlAttributes, $optionsHere), null, '', ' '); $individualTagName = "{$this->field}_{$optValue}"; $out[] = "<li>".sprintf($this->tags['radio'], $this->model, $this->field, $individualTagName, $parsedOptions, '<label for='.$individualTagName.'>'.$optTitle.'</label>')."</li>"; } $out = join($inbetween, $out); return "<ul id=".$this->field.">".$this->output($out ? $out : null, $return)."</ul>"; } </code> Anyone feel like helping me clean it up and extend it? I'd like to be able to pass htmlAttributes to the UL (to define a classname, ID, etc), but I'm not sure how to go about it. Additionally, my code is a quick hack which I am sure can be done more efficiently - this is quite literally a copy and mod of the existing html:radio helper. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~----------~----~----~----~------~----~------~--~---