コード例 #1
0
 protected function fieldWorkType()
 {
     $output = "";
     $allWorkTypes = WorkType::getAllRows();
     $output .= "<select name=\"" . static::workTypeIdFieldName . "\">\n";
     /* The following logic will determine the selected option */
     /* Chose a do...while() in order to avoid code duplication for the 'selected' option logic */
     $workTypeId = static::anyWorkTypeCode;
     $workTypeName = "Any work type";
     $firstRow = true;
     do {
         if (!$firstRow) {
             $workTypeId = WorkType::getWorkTypeId($row);
             $workTypeName = WorkType::getWorkTypeName($row);
         } else {
             $firstRow = false;
         }
         if ($this->searchedWorkTypeId == $workTypeId) {
             $selected = "selected";
         } else {
             $selected = "";
         }
         /* here is the actual option output */
         $output .= " <option {$selected} value =\"{$workTypeId}.\">{$workTypeName}</option>\n";
     } while (($row = $allWorkTypes->fetch_row()) != NULL);
     $output .= "</select>\n";
     return $output;
 }