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"; }
public function run() { if (!empty($this->masterAttributeName) && !empty($this->dependedAttributeName) && !empty($this->getDataUrl)) { echo ' <script type="text/javascript"> $(document).ready(function() { $("#' . EHtml::resolveId($this->model, $this->masterAttributeName) . '").bind("change", function() { var $dependObject = $("#' . EHtml::resolveId($this->model, $this->dependedAttributeName) . '"); $dependObject.html(""); if (!$(this).val()) { $dependObject.attr("disabled", "disabled"); } else { $dependObject.removeAttr("disabled"); $.get("' . $this->getDataUrl . '"+$(this).val(), function (data) { $dependObject.html(data); }); } }); }); </script> '; } }
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>"; }