error() public method

Displays the first validation error for a model attribute.
public error ( CModel $model, string $attribute, array $htmlOptions = [], boolean $enableAjaxValidation = true, boolean $enableClientValidation = true ) : string
$model CModel the data model
$attribute string the attribute name
$htmlOptions array additional HTML attributes to be rendered in the container div tag.
$enableAjaxValidation boolean whether to enable AJAX validation for the specified attribute.
$enableClientValidation boolean whether to enable client-side validation for the specified attribute.
return string the validation result (error display or success message).
Exemplo n.º 1
0
 public function run()
 {
     echo '<div class="control-group">';
     $htmlOptions['class'] = 'control-label';
     echo $this->form->labelEx($this->model, $this->attribute, $htmlOptions);
     echo '<div class="controls">';
     parent::run();
     echo $this->form->error($this->model, $this->attribute);
     echo "</div>";
     echo "</div>";
 }
Exemplo n.º 2
0
    public function run()
    {
        $idFrom = EHtml::resolveId($this->model, $this->attributeName);
        $idTo = EHtml::resolveId($this->model, $this->attributeDateTo);
        Yii::app()->clientScript->registerScript('datePickerInitialize', '
			$.datepicker.setDefaults( $.datepicker.regional["ru"] );
			$("#' . $idFrom . '").datepicker({
				onSelect: function( selectedDate ) {
					$( "#' . $idTo . '" ).datepicker( "option", "minDate", selectedDate );
				}
			});
			$("#' . $idTo . '").datepicker({
				onSelect: function( selectedDate ) {
					$( "#' . $idFrom . '" ).datepicker( "option", "maxDate", selectedDate );
				}
			});
		');
        echo "\n<style type='text/css'>\n.controls-line {\n\tmargin-bottom: 5px;\n}\n</style>\n<div class='control-group'>\n\t" . CHtml::activeLabelEx($this->model, $this->attributeName, array('class' => 'control-label')) . "\n\t<div class='controls controls-line'>\n\t\t<div class='input-append'>\n\t\t\t{$this->form->textField($this->model, $this->attributeName)}<span class='add-on'><i class='icon-calendar'></i></span>\n\t\t</div>\n\t\t<div class='input-append'>\n\t\t\t<label style='margin: 0 20px; display:inline;' for='" . $idTo . "'>\n\t\t\t\t{$this->model->getAttributeLabel($this->attributeDateTo)}\n\t\t\t</label>\n\t\t\t{$this->form->textField($this->model, $this->attributeDateTo)}<span class='add-on'><i class='icon-calendar'></i></span>\n\t\t</div>\n\t</div>\n\t<div class='controls'>\n\t\t{$this->form->error($this->model, $this->attributeName)}\n\t\t{$this->form->error($this->model, $this->attributeDateTo)}\n\t</div>\n</div>\n";
    }
Exemplo n.º 3
0
    public function run()
    {
        $model = $this->model;
        $attribute = $this->attribute;
        $form = $this->form;
        echo '<style type="text/css">
		.controls-line {
			margin-bottom: 5px;
		}
		</style>';
        echo '<div class="control-group">';
        $htmlOptions['class'] = 'control-label';
        echo CHtml::activeLabelEx($model, $attribute, $htmlOptions);
        if (is_array($model->{$attribute})) {
            foreach ($model->{$attribute} as $id => $value) {
                $thumbnail = $value;
                if (!empty($this->thumbnailImage)) {
                    $thumbnail = $this->evaluateExpression($this->thumbnailImage, array('data' => $model, 'value' => $value));
                }
                $image = $this->evaluateExpression($this->image, array('data' => $model, 'value' => $value));
                echo '<div class="controls controls-line">';
                echo CHtml::link(CHtml::image($thumbnail, '', array('style' => "max-width:{$this->maxImageSize}px; max-height:{$this->maxImageSize}px")), $image, array('target' => '_blank', 'style' => 'margin-right:1em'));
                echo '<label class="checkbox" style="display:inline-block" for="' . EHtml::resolveId($model, $this->removeImageFieldName . "[{$id}]") . '">';
                echo $form->checkBox($model, $this->removeImageFieldName . "[{$id}]");
                echo $model->getAttributeLabel($this->removeImageFieldName);
                echo '</label></div>';
            }
        }
        echo '<div class="controls">';
        echo $this->form->error($model, $this->uploadedFileFieldName);
        echo '</div>';
        $fileUploadTemplate = '<div class="controls">';
        $fileUploadTemplate .= CHtml::activeFileField($model, $this->uploadedFileFieldName . "[]");
        $fileUploadTemplate .= "</div>";
        $fileUploadTemplate = json_encode($fileUploadTemplate);
        echo '<div class="controls js-button">';
        $this->widget('bootstrap.widgets.TbButton', array('label' => 'Добавить изображение', 'icon' => 'plus'));
        echo "</div>";
        echo '<script type="text/javascript">
		$("div.js-button a").bind("click", function() {
			$(' . $fileUploadTemplate . ').insertBefore($(this).closest("div.controls")).show();
		});
		</script>';
        echo "</div>";
    }
Exemplo n.º 4
0
 /**
  * Create TbActiveForm widget.
  *
  * @param TbActiveForm $form
  * @param object $model Model
  * @param string $attribute Model attribute
  */
 public function createWidget($form, $model, $attribute)
 {
     $lang = Yii::app()->language;
     if ($lang == 'en_us') {
         $lang = 'en';
     }
     $widget = $this->getAttributeWidget($model, $attribute);
     switch ($widget) {
         case 'time':
             if ($form->type == TbActiveForm::TYPE_HORIZONTAL) {
                 echo '<div class="control-group">';
                 echo $form->labelEx($model, $attribute, array('class' => 'control-label'));
                 echo '<div class="controls">';
             } else {
                 echo $form->labelEx($model, $attribute);
             }
             echo '<div class="input-prepend"><span class="add-on"><i class="icon-time"></i></span>';
             $options = array('model' => $model, 'attribute' => $attribute, 'language' => $lang, 'mode' => 'time', 'htmlOptions' => array('class' => 'size-medium'), 'options' => array('timeFormat' => 'HH:mm:ss', 'showSecond' => true));
             $options = $this->getAttributeOptions($attribute, $options);
             $this->controller->widget($this->name . '.extensions.jui.EJuiDateTimePicker', $options);
             echo '</div>';
             echo $form->error($model, $attribute);
             if ($form->type == TbActiveForm::TYPE_HORIZONTAL) {
                 echo '</div></div>';
             }
             break;
         case 'datetime':
             if ($form->type == TbActiveForm::TYPE_HORIZONTAL) {
                 echo '<div class="control-group">';
                 echo $form->labelEx($model, $attribute, array('class' => 'control-label'));
                 echo '<div class="controls">';
             } else {
                 echo $form->labelEx($model, $attribute);
             }
             echo '<div class="input-prepend"><span class="add-on"><i class="icon-calendar"></i></span>';
             $options = array('model' => $model, 'attribute' => $attribute, 'language' => $lang, 'mode' => 'datetime', 'htmlOptions' => array('class' => 'size-medium'), 'options' => array('dateFormat' => 'yy-mm-dd', 'timeFormat' => 'HH:mm:ss', 'showSecond' => true));
             $options = $this->getAttributeOptions($attribute, $options);
             $this->controller->widget($this->name . '.extensions.jui.EJuiDateTimePicker', $options);
             echo '</div>';
             echo $form->error($model, $attribute);
             if ($form->type == TbActiveForm::TYPE_HORIZONTAL) {
                 echo '</div></div>';
             }
             break;
         case 'date':
             if ($form->type == TbActiveForm::TYPE_HORIZONTAL) {
                 echo '<div class="control-group">';
                 echo $form->labelEx($model, $attribute, array('class' => 'control-label'));
                 echo '<div class="controls">';
             } else {
                 echo $form->labelEx($model, $attribute);
             }
             echo '<div class="input-prepend"><span class="add-on"><i class="icon-calendar"></i></span>';
             $options = array('model' => $model, 'attribute' => $attribute, 'language' => $lang, 'mode' => 'date', 'htmlOptions' => array('class' => 'size-medium'), 'options' => array('dateFormat' => 'yy-mm-dd'));
             $options = $this->getAttributeOptions($attribute, $options);
             $this->controller->widget($this->name . '.extensions.jui.EJuiDateTimePicker', $options);
             echo '</div>';
             echo $form->error($model, $attribute);
             if ($form->type == TbActiveForm::TYPE_HORIZONTAL) {
                 echo '</div></div>';
             }
             break;
         case 'wysiwyg':
             if ($form->type == TbActiveForm::TYPE_HORIZONTAL) {
                 echo '<div class="control-group">';
                 echo $form->labelEx($model, $attribute, array('class' => 'control-label'));
                 echo '<div class="controls">';
             } else {
                 echo $form->labelEx($model, $attribute);
             }
             $options = array('model' => $model, 'attribute' => $attribute, 'options' => array('lang' => $lang, 'buttons' => array('formatting', '|', 'bold', 'italic', 'deleted', '|', 'unorderedlist', 'orderedlist', 'outdent', 'indent', '|', 'image', 'link', '|', 'html')));
             $options = $this->getAttributeOptions($attribute, $options);
             if ($this->redactorUpload === true) {
                 $redactorOptions = array('options' => array('imageUpload' => Yii::app()->createUrl($this->name . '/model/redactorImageUpload', array('name' => get_class($model), 'attr' => $attribute)), 'imageGetJson' => Yii::app()->createUrl($this->name . '/model/redactorImageList', array('name' => get_class($model), 'attr' => $attribute)), 'imageUploadErrorCallback' => new CJavaScriptExpression('function(obj,json) { alert(json.error); }')));
                 $options = array_merge_recursive($options, $redactorOptions);
             }
             $this->controller->widget($this->name . '.extensions.redactor.ERedactorWidget', $options);
             echo $form->error($model, $attribute);
             if ($form->type == TbActiveForm::TYPE_HORIZONTAL) {
                 echo '</div></div>';
             }
             break;
         case 'textArea':
             $options = array('rows' => 5, 'cols' => 50, 'class' => 'span8');
             $options = $this->getAttributeOptions($attribute, $options);
             echo $form->textAreaRow($model, $attribute, $options);
             break;
         case 'textField':
             $options = array('class' => 'span5');
             $options = $this->getAttributeOptions($attribute, $options);
             echo $form->textFieldRow($model, $attribute, $options);
             break;
         case 'chosen':
             $options = array('empty' => Yii::t('YcmModule.ycm', 'Choose {name}', array('{name}' => $model->getAttributeLabel($attribute))), 'class' => 'span5 chosen-select');
             $options = $this->getAttributeOptions($attribute, $options);
             $this->controller->widget($this->name . '.extensions.chosen.EChosenWidget');
             echo $form->dropDownListRow($model, $attribute, $this->getAttributeChoices($model, $attribute), $options);
             break;
         case 'chosenMultiple':
             $options = array('data-placeholder' => Yii::t('YcmModule.ycm', 'Choose {name}', array('{name}' => $model->getAttributeLabel($attribute))), 'multiple' => 'multiple', 'class' => 'span5 chosen-select');
             $options = $this->getAttributeOptions($attribute, $options);
             $this->controller->widget($this->name . '.extensions.chosen.EChosenWidget');
             echo $form->dropDownListRow($model, $attribute, $this->getAttributeChoices($model, $attribute), $options);
             break;
         case 'taggable':
             if ($form->type == TbActiveForm::TYPE_HORIZONTAL) {
                 echo '<div class="control-group">';
                 echo $form->labelEx($model, $attribute, array('class' => 'control-label'));
                 echo '<div class="controls">';
             } else {
                 echo $form->labelEx($model, $attribute);
             }
             $options = array('name' => $attribute, 'value' => $model->{$attribute}->toString(), 'url' => Yii::app()->createUrl($this->name . '/model/suggestTags', array('name' => get_class($model), 'attr' => $attribute)), 'multiple' => true, 'mustMatch' => false, 'matchCase' => false, 'htmlOptions' => array('size' => 50, 'class' => 'span5'));
             $options = $this->getAttributeOptions($attribute, $options);
             $this->controller->widget('CAutoComplete', $options);
             echo '<span class="help-inline">' . Yii::t('YcmModule.ycm', 'Separate words with commas.') . '</span>';
             echo $form->error($model, $attribute);
             if ($form->type == TbActiveForm::TYPE_HORIZONTAL) {
                 echo '</div></div>';
             }
             break;
         case 'dropDown':
             $options = array('empty' => Yii::t('YcmModule.ycm', 'Choose {name}', array('{name}' => $model->getAttributeLabel($attribute))), 'class' => 'span5');
             $options = $this->getAttributeOptions($attribute, $options);
             echo $form->dropDownListRow($model, $attribute, $this->getAttributeChoices($model, $attribute), $options);
             break;
         case 'typeHead':
             if ($form->type == TbActiveForm::TYPE_HORIZONTAL) {
                 echo '<div class="control-group">';
                 echo $form->labelEx($model, $attribute, array('class' => 'control-label'));
                 echo '<div class="controls">';
             } else {
                 echo $form->labelEx($model, $attribute);
             }
             $options = array('model' => $model, 'attribute' => $attribute, 'htmlOptions' => array('class' => 'span5', 'autocomplete' => 'off'), 'options' => array('name' => 'typeahead', 'source' => $this->getAttributeChoices($model, $attribute), 'matcher' => "js:function(item) {\n\t\t\t\t\t\t\treturn ~item.toLowerCase().indexOf(this.query.toLowerCase());\n\t\t\t\t\t\t}"));
             $options = $this->getAttributeOptions($attribute, $options, true);
             $this->controller->widget('bootstrap.widgets.TbTypeahead', $options);
             echo $form->error($model, $attribute);
             if ($form->type == TbActiveForm::TYPE_HORIZONTAL) {
                 echo '</div></div>';
             }
             break;
         case 'radioButton':
             $options = array();
             $options = $this->getAttributeOptions($attribute, $options);
             echo $form->radioButtonListRow($model, $attribute, $this->getAttributeChoices($model, $attribute), $options);
             break;
         case 'boolean':
             $options = array();
             $options = $this->getAttributeOptions($attribute, $options);
             echo $form->checkboxRow($model, $attribute, $options);
             break;
         case 'password':
             $options = array('class' => 'span5');
             $options = $this->getAttributeOptions($attribute, $options);
             echo $form->passwordFieldRow($model, $attribute, $options);
             break;
         case 'disabled':
             $options = array('class' => 'span5', 'disabled' => true);
             $options = $this->getAttributeOptions($attribute, $options);
             echo $form->textFieldRow($model, $attribute, $options);
             break;
         case 'file':
             $options = array('class' => 'span5');
             $options = $this->getAttributeOptions($attribute, $options);
             if (!$model->isNewRecord && !empty($model->{$attribute})) {
                 ob_start();
                 echo '<p>';
                 $this->controller->widget('bootstrap.widgets.TbButton', array('label' => Yii::t('YcmModule.ycm', 'Download'), 'type' => '', 'url' => $model->getFileUrl($attribute)));
                 echo '</p>';
                 $html = ob_get_clean();
                 $options['hint'] = $html;
             }
             echo $form->fileFieldRow($model, $attribute, $options);
             break;
         case 'image':
             $options = array('class' => 'span5');
             $options = $this->getAttributeOptions($attribute, $options);
             if (!$model->isNewRecord && !empty($model->{$attribute})) {
                 $modalName = 'modal-image-' . $attribute;
                 $image = CHtml::image($model->getFileUrl($attribute), Yii::t('YcmModule.ycm', 'Image'), array('class' => 'modal-image'));
                 ob_start();
                 $this->controller->beginWidget('bootstrap.widgets.TbModal', array('id' => $modalName));
                 echo '<div class="modal-header"><a class="close" data-dismiss="modal">&times;</a><h4>';
                 echo Yii::t('YcmModule.ycm', 'Image preview') . '</h4></div>';
                 echo '<div class="modal-body">' . $image . '</div>';
                 $this->controller->endWidget();
                 echo '<p>';
                 $this->controller->widget('bootstrap.widgets.TbButton', array('label' => Yii::t('YcmModule.ycm', 'Preview'), 'type' => '', 'htmlOptions' => array('data-toggle' => 'modal', 'data-target' => '#' . $modalName)));
                 echo '</p>';
                 $html = ob_get_clean();
                 $options['hint'] = $html;
             }
             echo $form->fileFieldRow($model, $attribute, $options);
             break;
         case 'hide':
             break;
         default:
             $options = array('class' => 'span5');
             $options = $this->getAttributeOptions($attribute, $options);
             echo $form->textFieldRow($model, $attribute, $options);
             break;
     }
 }
Exemplo n.º 5
0
	<p class="help-block">Fields with <span class="required">*</span> are required.</p>

	<?php 
if (empty($SpecialityID)) {
    $SpecialityID = 0;
}
echo CHtml::dropDownList("SpecialityID", $SpecialityID, Specialities::DropDown(), array('empty' => "", 'class' => 'span5'));
$c = new CDbCriteria();
$c->order = 'SubjectName';
$c->compare('idZNOSubject', '>0');
$data = CHtml::listData(Subjects::model()->findAll($c), "idSubjects", "SubjectName");
$dataCount = count($data);
?>
        <div class ="row-fluid">
            <?php 
echo $form->error($models[0], "SpecialityID");
?>
        </div>
        
        <div class ="row-fluid">
            <?php 
foreach ($models as $i => $model) {
    ?>
            <div class="span4">
                <?php 
    echo $form->error($model, "[{$i}]SubjectID");
    ?>
                <?php 
    echo $form->textFieldRow($model, "[{$i}]LevelID", array('class' => 'span12', "readonly" => "readonly"));
    ?>
                <?php 
Exemplo n.º 6
0
//        $dataCount  = count($data);
//
//        unset($c);
$Specialities = new Specialities();
$d = $Specialities->getSpecialityFullNames();
?>
        <div class ="row-fluid">

        </div>
        
        <div class ="row-fluid">
            
            <div class="span4">

                <?php 
echo $form->error($model, "SubjectID");
?>
                <?php 
echo $form->dropDownListRow($model, "SpecialityID", $d, array('class' => 'span12'));
?>
                <?php 
echo $form->textFieldRow($model, "LevelID", array('class' => 'span12', "readonly" => "readonly"));
?>
                <?php 
echo $form->dropDownListRow($model, "SubjectID", CHtml::listData(Subjects::model()->findAll(), "idSubjects", "SubjectName"), array('class' => 'span12'));
?>
                <?php 
echo "Це профільний предмет?";
echo $form->radioButtonList($model, "isProfile", array(0 => "ні", 1 => "так"), array('separator' => ' '));
?>
            </div>
Exemplo n.º 7
0
 /**
  * Create TbActiveForm widget.
  *
  * @param TbActiveForm $form
  * @param object $model Model
  * @param string $attribute Model attribute
  */
 public function createWidget($form, $model, $attribute, $extraOptions = '', $extraHtml = '')
 {
     $lang = Yii::app()->language;
     if ($lang == 'en_us') {
         $lang = 'en';
     }
     $widget = $this->getAttributeWidget($model, $attribute);
     switch ($widget) {
         case 'time':
             if ($form->type == TbActiveForm::TYPE_HORIZONTAL) {
                 echo '<div class="control-group">';
                 echo $form->labelEx($model, $attribute, array('class' => 'control-label'));
                 echo '<div class="controls">';
             } else {
                 echo $form->labelEx($model, $attribute);
             }
             echo '<div class="input-prepend"><span class="add-on"><i class="icon-time"></i></span>';
             $options = array('model' => $model, 'attribute' => $attribute, 'language' => $lang, 'mode' => 'time', 'htmlOptions' => array('class' => 'size-medium'), 'options' => array('timeFormat' => 'HH:mm', 'showSecond' => false, 'stepMinute' => '10'));
             $options = $this->getAttributeOptions($attribute, $options);
             $this->controller->widget($this->name . '.extensions.jui.EJuiDateTimePicker', $options);
             echo '</div>';
             echo $form->error($model, $attribute);
             if ($form->type == TbActiveForm::TYPE_HORIZONTAL) {
                 echo '</div></div>';
             }
             break;
         case 'datetime':
             if ($form->type == TbActiveForm::TYPE_HORIZONTAL) {
                 echo '<div class="control-group">';
                 echo $form->labelEx($model, $attribute, array('class' => 'control-label'));
                 echo '<div class="controls">';
             } else {
                 echo $form->labelEx($model, $attribute);
             }
             echo '<div class="input-prepend"><span class="add-on"><i class="icon-calendar"></i></span>';
             $options = array('model' => $model, 'attribute' => $attribute, 'language' => $lang, 'mode' => 'datetime', 'htmlOptions' => array('class' => 'size-medium'), 'options' => array('dateFormat' => 'yy-mm-dd', 'timeFormat' => 'HH:mm', 'showSecond' => false));
             $options = $this->getAttributeOptions($attribute, $options);
             $this->controller->widget($this->name . '.extensions.jui.EJuiDateTimePicker', $options);
             echo '</div>';
             echo $form->error($model, $attribute);
             if ($form->type == TbActiveForm::TYPE_HORIZONTAL) {
                 echo '</div></div>';
             }
             break;
         case 'date':
             if ($form->type == TbActiveForm::TYPE_HORIZONTAL) {
                 echo '<div class="control-group">';
                 echo $form->labelEx($model, $attribute, array('class' => 'control-label'));
                 echo '<div class="controls">';
             } else {
                 echo $form->labelEx($model, $attribute);
             }
             echo '<div class="input-prepend"><span class="add-on"><i class="icon-calendar"></i></span>';
             $options = array('model' => $model, 'attribute' => $attribute, 'language' => $lang, 'mode' => 'date', 'htmlOptions' => array('class' => 'size-medium'), 'options' => array('dateFormat' => 'yy-mm-dd', 'changeMonth' => true, 'changeYear' => true, 'yearRange' => '1998:2030'));
             $options = $this->getAttributeOptions($attribute, $options);
             $this->controller->widget($this->name . '.extensions.jui.EJuiDateTimePicker', $options);
             echo '</div>';
             echo $form->error($model, $attribute);
             if ($form->type == TbActiveForm::TYPE_HORIZONTAL) {
                 echo '</div></div>';
             }
             break;
         case 'wysiwyg':
             if ($form->type == TbActiveForm::TYPE_HORIZONTAL) {
                 echo '<div class="control-group">';
                 echo $form->labelEx($model, $attribute, array('class' => 'control-label'));
                 echo '<div class="controls">';
             } else {
                 echo $form->labelEx($model, $attribute);
             }
             $options = array('model' => $model, 'attribute' => $attribute, 'options' => array('lang' => $lang, 'buttons' => array('formatting', '|', 'bold', 'italic', 'deleted', '|', 'unorderedlist', 'orderedlist', 'outdent', 'indent', '|', 'image', 'link', '|', 'html')));
             $options = $this->getAttributeOptions($attribute, $options);
             if ($this->redactorUpload === true) {
                 $redactorOptions = array('options' => array('imageUpload' => Yii::app()->createUrl($this->name . '/model/redactorImageUpload', array('name' => get_class($model), 'attr' => $attribute)), 'imageGetJson' => Yii::app()->createUrl($this->name . '/model/redactorImageList', array('name' => get_class($model), 'attr' => $attribute)), 'imageUploadErrorCallback' => new CJavaScriptExpression('function(obj,json) { alert(json.error); }')));
                 $options = array_merge_recursive($options, $redactorOptions);
             }
             $this->controller->widget($this->name . '.extensions.redactor.ERedactorWidget', $options);
             echo $form->error($model, $attribute);
             if ($form->type == TbActiveForm::TYPE_HORIZONTAL) {
                 echo '</div></div>';
             }
             break;
         case 'textArea':
             $options = array('rows' => 5, 'cols' => 50, 'class' => 'span8');
             $data_caracters = '';
             foreach ($model->getValidators($attribute) as $validator) {
                 if ($validator instanceof CStringValidator && $validator->max !== null) {
                     $data_caracters = 'Cantidad de caracteres permitidos (' . $validator->max . ' max.)';
                     break;
                 }
             }
             $options = $this->getAttributeOptions($attribute, $options);
             echo $form->textAreaRow($model, $attribute, $options);
             echo "<span class='textnum' data-caracters='{$data_caracters}'></span>";
             break;
         case 'textField':
             $options = array('class' => 'span5');
             if ($extraOptions != '' && isset($extraOptions[$attribute])) {
                 $options = $extraOptions[$attribute];
             }
             $data_caracters = '';
             foreach ($model->getValidators($attribute) as $validator) {
                 if ($validator instanceof CStringValidator && $validator->max !== null) {
                     $data_caracters = 'Cantidad de caracteres permitidos (' . $validator->max . ' max.)';
                     break;
                 }
             }
             $options = $this->getAttributeOptions($attribute, $options);
             echo $form->textFieldRow($model, $attribute, $options);
             echo "<span class='textnum' data-caracters='{$data_caracters}'></span>";
             break;
         case 'chosen':
             $options = array('empty' => Yii::t('YcmModule.ycm', 'Selecciona {name}', array('{name}' => strtolower($model->getAttributeLabel($attribute)))), 'class' => 'span5 chosen-select');
             $options = $this->getAttributeOptions($attribute, $options);
             $this->controller->widget($this->name . '.extensions.chosen.EChosenWidget');
             echo $form->dropDownListRow($model, $attribute, $this->getAttributeChoices($model, $attribute), $options);
             if ($extraHtml != '' && isset($extraHtml[$attribute])) {
                 echo $extraHtml[$attribute];
             }
             break;
         case 'chosenMultiple':
             $options = array('data-placeholder' => Yii::t('YcmModule.ycm', 'Selecciona {name}', array('{name}' => strtolower($model->getAttributeLabel($attribute)))), 'multiple' => 'multiple', 'class' => 'span5 chosen-select');
             $options = $this->getAttributeOptions($attribute, $options);
             $this->controller->widget($this->name . '.extensions.chosen.EChosenWidget');
             echo $form->dropDownListRow($model, $attribute, $this->getAttributeChoices($model, $attribute), $options);
             if ($extraHtml != '' && isset($extraHtml[$attribute])) {
                 echo $extraHtml[$attribute];
             }
             break;
         case 'taggable':
             if ($form->type == TbActiveForm::TYPE_HORIZONTAL) {
                 echo '<div class="control-group">';
                 echo $form->labelEx($model, $attribute, array('class' => 'control-label'));
                 echo '<div class="controls">';
             } else {
                 echo $form->labelEx($model, $attribute);
             }
             $options = array('name' => $attribute, 'value' => $model->{$attribute}->toString(), 'url' => Yii::app()->createUrl($this->name . '/model/suggestTags', array('name' => get_class($model), 'attr' => $attribute)), 'multiple' => true, 'mustMatch' => false, 'matchCase' => false, 'htmlOptions' => array('size' => 50, 'class' => 'span5'));
             $options = $this->getAttributeOptions($attribute, $options);
             $this->controller->widget('CAutoComplete', $options);
             echo '<span class="help-inline">' . Yii::t('YcmModule.ycm', 'Separate words with commas.') . '</span>';
             echo $form->error($model, $attribute);
             if ($form->type == TbActiveForm::TYPE_HORIZONTAL) {
                 echo '</div></div>';
             }
             break;
         case 'dropDown':
             $options = array('empty' => Yii::t('YcmModule.ycm', 'Selecciona {name}', array('{name}' => strtolower($model->getAttributeLabel($attribute)))), 'class' => 'span5');
             $options = $this->getAttributeOptions($attribute, $options);
             echo $form->dropDownListRow($model, $attribute, $this->getAttributeChoices($model, $attribute), $options);
             break;
         case 'typeHead':
             if ($form->type == TbActiveForm::TYPE_HORIZONTAL) {
                 echo '<div class="control-group">';
                 echo $form->labelEx($model, $attribute, array('class' => 'control-label'));
                 echo '<div class="controls">';
             } else {
                 echo $form->labelEx($model, $attribute);
             }
             $options = array('model' => $model, 'attribute' => $attribute, 'htmlOptions' => array('class' => 'span5', 'autocomplete' => 'off'), 'options' => array('name' => 'typeahead', 'source' => $this->getAttributeChoices($model, $attribute), 'matcher' => "js:function(item) {\n\t\t\t\t\t\t\treturn ~item.toLowerCase().indexOf(this.query.toLowerCase());\n\t\t\t\t\t\t}"));
             $options = $this->getAttributeOptions($attribute, $options, true);
             $this->controller->widget('bootstrap.widgets.TbTypeahead', $options);
             echo $form->error($model, $attribute);
             if ($form->type == TbActiveForm::TYPE_HORIZONTAL) {
                 echo '</div></div>';
             }
             break;
         case 'radioButton':
             $options = array();
             $options = $this->getAttributeOptions($attribute, $options);
             echo $form->radioButtonListRow($model, $attribute, $this->getAttributeChoices($model, $attribute), $options);
             break;
         case 'boolean':
             $options = array();
             $options = $this->getAttributeOptions($attribute, $options);
             echo $form->checkboxRow($model, $attribute, $options);
             break;
         case 'password':
             $options = array('class' => 'span5');
             $options = $this->getAttributeOptions($attribute, $options);
             echo $form->passwordFieldRow($model, $attribute, $options);
             break;
         case 'disabled':
             $options = array('class' => 'span5', 'disabled' => true);
             $options = $this->getAttributeOptions($attribute, $options);
             echo $form->textFieldRow($model, $attribute, $options);
             break;
         case 'file':
             $options = array('class' => 'span5');
             $options = $this->getAttributeOptions($attribute, $options);
             if (!$model->isNewRecord && !empty($model->{$attribute})) {
                 ob_start();
                 echo '<p>';
                 $this->controller->widget('bootstrap.widgets.TbButton', array('label' => Yii::t('YcmModule.ycm', 'Descargar'), 'type' => '', 'url' => $model->getFileUrl($attribute), 'htmlOptions' => array('target' => '_blank')));
                 echo '</p>';
                 $html = ob_get_clean();
                 $options['hint'] = $html;
             }
             echo $form->fileFieldRow($model, $attribute, $options);
             break;
         case 'image':
             $options = array('class' => 'span5');
             if ($extraOptions != '' && isset($extraOptions[$attribute])) {
                 $options = $extraOptions[$attribute];
             }
             $options = $this->getAttributeOptions($attribute, $options);
             if (!$model->isNewRecord && !empty($model->{$attribute})) {
                 $modalName = 'modal-image-' . $attribute;
                 $image = CHtml::image($model->getFileUrl($attribute), Yii::t('YcmModule.ycm', 'Image'), array('class' => 'modal-image'));
                 ob_start();
                 $this->controller->beginWidget('bootstrap.widgets.TbModal', array('id' => $modalName));
                 echo '<div class="modal-header"><a class="close" data-dismiss="modal">&times;</a><h4>';
                 echo Yii::t('YcmModule.ycm', 'Image preview') . '</h4></div>';
                 echo '<div class="modal-body">' . $image . '</div>';
                 $this->controller->endWidget();
                 echo '<p>';
                 $this->controller->widget('bootstrap.widgets.TbButton', array('label' => Yii::t('YcmModule.ycm', 'Vista previa'), 'type' => '', 'htmlOptions' => array('data-toggle' => 'modal', 'data-target' => '#' . $modalName)));
                 echo '</p>';
                 $html = ob_get_clean();
                 $options['hint'] = $html;
             }
             echo $form->fileFieldRow($model, $attribute, $options);
             echo '<span class="filetext"></span>';
             if ($model->allowDelImage() && !$model->isAttributeRequired($attribute)) {
                 echo '<div class="control-group ">
                                         <label for="__link" class="control-label"></label>
                                         <div class="controls">
                                             <label for="eliminate_image_' . $attribute . '" class="checkbox">
                                                 <input type="hidden" name="eliminate_image[' . $attribute . ']" value="0" id="yteliminate_image_' . $attribute . '">
                                                 <input type="checkbox" value="1" id="eliminate_image_' . $attribute . '" name="eliminate_image[' . $attribute . ']"><span style="font-style: italic;">Eliminar imagen</span>
                                             </label>
                                         </div>
                                     </div>';
             }
             if ($extraHtml != '' && isset($extraHtml[$attribute])) {
                 echo $extraHtml[$attribute];
             }
             break;
         case 'hide':
             break;
         case 'label':
             $options = array('class' => 'span5');
             $options = $this->getAttributeOptions($attribute, $options);
             echo '<div class="control-group">';
             echo '<label class="control-label">' . $model->getAttributeLabel($attribute) . ':</label>';
             echo '<div class="controls">';
             echo '<label style="font-style: italic; padding-top: 5px;">', $model->grado, '</label>';
             echo '</div>';
             echo '</div>';
             break;
         default:
             $options = array('class' => 'span5');
             $data_caracters = '';
             foreach ($model->getValidators($attribute) as $validator) {
                 if ($validator instanceof CStringValidator && $validator->max !== null) {
                     $data_caracters = 'Cantidad de caracteres permitidos (' . $validator->max . ' max.)';
                     break;
                 }
             }
             $options = $this->getAttributeOptions($attribute, $options);
             echo $form->textFieldRow($model, $attribute, $options);
             echo "<span class='textnum' data-caracters='{$data_caracters}'></span>";
             break;
     }
 }