示例#1
0
 public function fileField($model, $attribute, $htmlOptions = array())
 {
     $controlOptions = BsArray::popValue('controlOptions', $htmlOptions, array());
     $labelOptions = BsArray::popValue('labelOptions', $htmlOptions, array());
     $layout = $this->layout;
     $output = '';
     $output .= CHtml::activeFileField($model, $attribute, $htmlOptions);
     $attr = $model->{$attribute};
     if (!empty($attr)) {
         //Special logic for ContentTypes
         $tmpModel = $model;
         if ($model instanceof ContentType) {
             $tmpModel = $model->Content;
         }
         $output .= '<p class="file">' . CHtml::link($model->{$attribute}, array('/site/getFile', 'id' => $tmpModel->id, 'field' => $attribute, 'modelName' => get_class($tmpModel))) . '</p>';
         $output .= '<div class="checkbox">' . CHtml::checkBox($attribute . '_delete');
         $output .= CHtml::label('Delete?', $attribute . '_delete') . '</div>';
     }
     $htmlOptions['input'] = $output;
     $htmlOptions['labelOptions'] = BsHtml::setLabelOptionsByLayout($layout, $labelOptions);
     if (!empty($layout)) {
         if ($layout === BsHtml::FORM_LAYOUT_HORIZONTAL) {
             $controlClass = BsArray::popValue('class', $controlOptions, BsHtml::$formLayoutHorizontalControlClass);
             BsHtml::addCssClass($controlClass, $htmlOptions['controlOptions']);
         }
     }
     return BsHTML::activeTextFieldControlGroup($model, $attribute, $htmlOptions);
 }
示例#2
0
 /**
  * Processes the options for a input row.
  * @param CModel $model the data model.
  * @param string $attribute the attribute name.
  * @param array $htmlOptions the options.
  * @return array the processed options.
  */
 protected function processRowOptions($model, $attribute, $options)
 {
     $errorOptions = BsArray::popValue('errorOptions', $options, array());
     $errorOptions['type'] = $this->helpType;
     $error = $this->error($model, $attribute, $errorOptions);
     // kind of a hack for ajax forms but this works for now.
     if (!empty($error) && strpos($error, 'display:none') === false) {
         $options['color'] = BsHtml::INPUT_COLOR_ERROR;
     }
     if (!$this->hideInlineErrors) {
         $options['error'] = $error;
     }
     $helpOptions = BsArray::popValue('helpOptions', $options, array());
     $helpOptions['type'] = $this->helpType;
     $labelOptions = BsArray::popValue('labelOptions', $options, array());
     $options['helpOptions'] = $helpOptions;
     $options['labelOptions'] = BsHtml::setLabelOptionsByLayout($this->layout, $labelOptions);
     $options['formLayout'] = $this->layout;
     return $options;
 }