Пример #1
0
 function renderControl($control, $data, $prefix = '')
 {
     // Print out a label for the control
     print '<label' . Html::attributes(array('for' => $control->id)) . '>' . Html::encode($control->caption) . ($control->required ? '<span class="required">*</span>' : '') . '</label>';
     if ($control->prefix) {
         print Html::encode($control->prefix);
     }
     if ($control instanceof Element_Input) {
         $attributes = $control->getAttributes($data, $prefix);
         // Add an error class to controls with issues
         if ($control->error) {
             $attributes['class'][] = 'error';
         }
         print '<input' . Html::attributes($attributes) . '>';
     } elseif ($control instanceof Element_Select) {
         $attributes = $control->getAttributes($data, $prefix);
         print '<select' . Html::attributes($attributes) . '>' . "\n";
         $value = $control->getValue($data);
         print Element_Select::renderOptions($control->options, $value, $control->multiple);
         print '</select>';
     } else {
         throw new Exception('Unknown control type for renderControl');
     }
     if ($control->suffix) {
         print Html::encode($control->suffix);
     }
     print "\n";
 }