00001 <?PHP 00017 include_once("OptionElement.php"); 00018 00027 class Radio extends OptionElement 00028 { 00029 00035 public function render() 00036 { 00037 $fromList = array(); 00038 $this->getFromList($fromList); 00039 $disabledStr = ($this->getEnabled() == "N") ? "DISABLED=\"true\"" : ""; 00040 if(!$this->m_Style){ 00041 $this->m_Style.="margin-right:8px;"; 00042 } 00043 $style = $this->getStyle(); 00044 $func = $this->getFunction(); 00045 00046 $value = $this->getValue()!='null' ? $this->getValue() : $this->getDefaultValue(); 00047 00048 $value = $value===null?$this->getDefaultValue():$value; 00049 00050 if($this->m_Width){ 00051 00052 $width = (int)$this->m_Width."px;"; 00053 }else{ 00054 $width = "auto;"; 00055 } 00056 foreach ($fromList as $option) { 00057 $checkedStr = ($option['val'] == $value) ? "CHECKED" : ""; 00058 $sHTML .= "<label style=\"text-align:left;width:$width\" class=\"radio_option\"><INPUT TYPE=RADIO NAME='".$this->m_Name."' ID=\"" . $this->m_Name ."_".$option['val']."\" VALUE=\"" . $option['val'] . "\" $checkedStr $disabledStr $style $this->m_HTMLAttr $func />" . $option['txt'] . "</label>"; 00059 } 00060 00061 return $sHTML; 00062 } 00063 00064 public function getStyle() 00065 { 00066 00067 $formobj = $this->getFormObj(); 00068 $htmlClass = Expression::evaluateExpression($this->m_cssClass, $formobj); 00069 $htmlClass = "CLASS='$htmlClass'"; 00070 if(!$htmlClass){ 00071 $htmlClass = null; 00072 } 00073 $style =''; 00074 00075 if ($this->m_Height && $this->m_Height>=0) 00076 $style .= "height:".$this->m_Height."px;"; 00077 if ($this->m_Style) 00078 $style .= $this->m_Style; 00079 if (!isset($style) && !$htmlClass) 00080 return null; 00081 if (isset($style)) 00082 { 00083 00084 $style = Expression::evaluateExpression($style, $formobj); 00085 $style = "STYLE='$style'"; 00086 } 00087 if($formobj->m_Errors[$this->m_Name]) 00088 { 00089 $htmlClass = "CLASS='".$this->m_cssErrorClass."'"; 00090 } 00091 if ($htmlClass) 00092 $style = $htmlClass." ".$style; 00093 return $style; 00094 00095 } 00096 } 00097 00098 ?>