<?php
/**
 * @copyright (c) Kufer Software GmbH, Loisachstrasse 4, D-84453 Mühldorf
 */

 


 class FormVarRadioGrp extends FormVarBasic
 {
   

   
   public function __construct(
     $formvarna,
     $formname,
     $formtext,
     $formoptary = null,
     $formopt0txt = '',
     $formgrptxt = ''
   ) {
     
     FormVar::__construct($formvarna, $formname, $formtext, $formoptary, $formopt0txt, $formgrptxt);
   }

   
   public function ausgabeFormElem()
   {
     
     FormVarBasic::ausgabeFormElem();
     echo "<tr><th class='form'></th>";
     echo $this->getRadioButtonGrp() . '</tr>';
   }

   
   
   public function getRadioButtonGrp()
   {
     $anzbuttons = count($this->formoptary);
     $formcheck = array();
     
     
     
     
     for ($i = 0;$i < $anzbuttons;$i++) {
       $formcheck[$i] = '';
       if (!empty($this->formoptary[$i]->formvarhlp)) {
         if (($this->formoptary[$i]->formvarna == $this->formoptary[$i]->formoptkey)
                     && ($this->formoptary[$i]->formvarhlp)) {
           $formcheck[$i] = 'checked';
         } elseif ($this->formoptary[$i]->formvarna == $this->formoptary[$i]->formoptkey) {
           $formcheck[$i] = 'checked';
         }
       }
     }
     $radiogrp = '';
     for ($i = 0;$i < $anzbuttons;$i++) {
       $radiogrp .= $this->formoptary[$i]->getFormElem($formcheck[$i]);
     }

     return $radiogrp;
   }
 }