1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11:
12:
13: 14: 15: 16: 17: 18: 19: 20:
21: class Form_Element_Radio extends Form_Element_Multi
22: {
23: 24: 25: 26: 27: 28: 29:
30: public function __construct($nom,$form)
31: {
32: parent::__construct($nom,$form);
33: $this->attrs['type'] = 'radio';
34: }
35:
36: 37: 38: 39: 40:
41: public function __toString()
42: {
43: $css = $this->cssClass();
44: $label = '';
45: if(!empty($this->label))
46: {
47: $label = "\t".'<span class="'.$this->cssLabel.'">'.$this->label.'</span>'."\n";
48: if(!empty($this->info))
49: $label.="\t".'<img src="'.$this->imgInfo.'" id="'.$this->attrs['name'].'_tooltip" class="form_tooltip" title="'.$this->info.'" alt="" style="cursor:help;" />';
50: if($this->labelNewLine)
51: $label.="\t".'<br />'."\n";
52: }
53:
54: $field='';
55: $attributs = $this->attrsToString();
56:
57: $value = $this->form->getPostedvalue($this->attrs['name']);
58: if($value=='')
59: $value = $this->value;
60:
61: foreach($this->choix as $valhtml=>$valAffichee)
62: {
63: if($value == $valhtml)
64: $checked = ' checked="checked"';
65: else
66: $checked = '';
67:
68: $field.="\t".'<input '.$css.' value="'.htmlspecialchars($valhtml).'" '.$attributs.$checked.' /> '.$valAffichee ."\n";
69: if($this->fieldNewLine)
70: $field.="\t".'<br />'."\n";
71: }
72: $error = '';
73: if(!is_null($this->errorMsg))
74: {
75: $error='<span class="'.$this->errorClass.'">'.$this->errorMsg.'</span><br />';
76: }
77: return $label.$field.$error;
78: }
79: }
80: ?>