예제 #1
0
 /**
  * Runs the widget.
  */
 public function run()
 {
     list($name, $id) = $this->resolveNameID();
     $id = $this->resolveId($id);
     echo TbHtml::openTag('div', array('class' => 'select2'));
     if ($this->hasModel()) {
         if ($this->asDropDownList) {
             echo TbHtml::activeDropDownList($this->model, $this->attribute, $this->data, $this->htmlOptions);
         } else {
             echo TbHtml::activeHiddenField($this->model, $this->attribute, $this->htmlOptions);
         }
     } else {
         if ($this->asDropDownList) {
             echo TbHtml::dropDownList($name, $this->value, $this->data, $this->htmlOptions);
         } else {
             echo TbHtml::hiddenField($name, $this->value, $this->htmlOptions);
         }
     }
     echo '</div>';
     if ($this->assetPath !== false) {
         $this->publishAssets($this->assetPath);
         $this->registerCssFile('/select2.css');
         if ($this->registerJs) {
             $this->registerScriptFile('/select2.js', CClientScript::POS_END);
         }
     }
     if ($this->bindPlugin) {
         $options = !empty($this->pluginOptions) ? CJavaScript::encode($this->pluginOptions) : '';
         $this->getClientScript()->registerScript(__CLASS__ . '#' . $id, "jQuery('#{$id}').select2({$options});");
     }
 }
예제 #2
0
 /**
  * Renders the select2 field
  */
 public function renderField()
 {
     list($name, $id) = $this->resolveNameID();
     TbArray::defaultValue('id', $id, $this->htmlOptions);
     TbArray::defaultValue('name', $name, $this->htmlOptions);
     if ($this->hasModel()) {
         echo $this->asDropDownList ? TbHtml::activeDropDownList($this->model, $this->attribute, $this->data, $this->htmlOptions) : TbHtml::activeHiddenField($this->model, $this->attribute);
     } else {
         echo $this->asDropDownList ? TbHtml::dropDownList($this->name, $this->value, $this->data, $this->htmlOptions) : TbHtml::hiddenField($this->name, $this->value);
     }
 }
예제 #3
0
파일: FImges.php 프로젝트: cooltheo/fircms
    public function renderImages()
    {
        $html = <<<EOF
        <div id='imagesnow' style='display:none;min-height:330px;border:1px dashed slategray;overflow-x:scroll;' onload="startimagesnow">
    <ul id="sortable"></ul>
</div>
EOF;
        echo CHtml::openTag('div', array('class' => 'controls'));
        echo $html;
        echo TbHtml::button("图片预览", array('id' => 'Post_togglemagesnow'));
        echo TbHtml::button("上传图片", array('id' => 'Post_selectImage'));
        echo TbHtml::activeHiddenField($this->model, 'images');
        echo CHtml::closeTag('div');
    }
예제 #4
0
<?php

/* @var $this DefaultController */
Yii::import('application.modules.user.models.User');
$modelClass = get_class($news);
$this->widget('bootstrap.widgets.TbBreadcrumb', array('links' => array(Yii::t('main', ucfirst($this->module->id)) => Yii::app()->createUrl($this->module->id), Yii::t('main', ucfirst($this->action->id)))));
?>

<?php 
$this->widget('bootstrap.widgets.TbAlert', array('block' => true, 'fade' => true, 'closeText' => '×', 'alerts' => array('success' => array('block' => true, 'fade' => true, 'closeText' => '×'), 'error' => array('block' => true, 'fade' => true, 'closeText' => '×'))));
$form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array('id' => 'news-form', 'layout' => TbHtml::FORM_LAYOUT_HORIZONTAL, 'htmlOptions' => array('enctype' => 'multipart/form-data')));
//show errors (for all models)
echo $form->errorSummary(array($news, $post, $portfolio), null, null, array('class' => 'alert-error'));
//hidden field for post_type (set by defined controller)
echo TbHtml::activeHiddenField($post, 'post_type');
?>

    <div class="control-group">
        <?php 
echo TbHtml::activeLabelEx($news, 'publication_date', array('class' => 'control-label'));
?>
        <div class="controls">
            <?php 
$this->widget('yiiwheels.widgets.datetimepicker.WhDateTimePicker', array('name' => $modelClass . '[publication_date]', 'id' => $modelClass . '_publication_date', 'value' => $news->publication_date, 'format' => 'yyyy-MM-dd hh:mm:ss', 'pluginOptions' => array()));
?>
        </div>
    </div>    

    <?php 
//echo $form->dropDownListControlGroup($news, 'user_id', CHtml::listData(User::model()->findAll(), 'user_id', 'email'), array('size'=>1));
?>