Пример #1
0
 /**
  * Helper function for generating simple radio button HTML fragments
  *
  * @param Zend_Form_Element_Radio $element
  * @param string $cssEtc optional attribute string for <input> tags
  * @param string $wrapInputHtml optional HTML that wraps each <input>, split by an asterisk
  * @param string $wrapLabelHtml optional HTML that wraps each <label>, split by an asterisk
  *
  * @return string
  */
 public function simpleRadio($element, $cssEtc = '', $wrapInputHtml = '', $wrapLabelHtml = '')
 {
     $wrapInputHtmlStart = $wrapInputHtmlEnd = $wrapLabelHtmlStart = $wrapLabelHtmlEnd = '';
     if (strpos($wrapInputHtml, '*') !== false) {
         list($wrapInputHtmlStart, $wrapInputHtmlEnd) = explode('*', $wrapInputHtml);
     }
     if (strpos($wrapLabelHtml, '*') !== false) {
         list($wrapLabelHtmlStart, $wrapLabelHtmlEnd) = explode('*', $wrapLabelHtml);
     }
     $output = '';
     $options = $element->getMultiOptions();
     foreach ($options as $key => $val) {
         $output .= sprintf("%s<input type=\"radio\" name=\"%s\" id=\"%s\" value=\"%s\" %s%s/>%s<label for=\"%s\">%s</label>%s%s\n", $wrapInputHtmlStart, $element->getName(), $element->getId() . '-' . $key, $key, (string) $key == (string) $element->getValue() && $key !== '' ? ' checked="checked"' : '', $cssEtc != '' ? " {$cssEtc}" : '', $wrapLabelHtmlStart, $element->getId() . '-' . $key, $val, $wrapLabelHtmlEnd, $wrapInputHtmlEnd);
     }
     return $output;
 }