Пример #1
1
    function run()
    {
        parent::run();
        $wid = $this->options['id'];
        echo Html::activeHiddenInput($this->model, $this->attribute);
        echo Html::beginTag('div', ['id' => $wid . '-buttons', 'class' => 'input-group btn-group']);
        $items = PublishBehavior::getPublishedOptions();
        $colors = PublishBehavior::getPublishedColors();
        foreach ($items as $key => $item) {
            echo Html::button($item, ['data' => ['value' => $key], 'class' => $key == $this->model->{$this->attribute} ? 'btn btn-' . $colors[$key] . ' active' : 'btn btn-default']);
        }
        echo Html::endTag('div');
        $js_colors = Json::encode($colors);
        $js = <<<JS
 \$('#{$wid}-buttons').find('button').each(function(){
   \$(this).on('click',function(){
     \$('#{$wid}-buttons').find('button').each(function(){
        \$(this).removeClass('btn-danger btn-warning btn-success btn-info active');
        \$(this).addClass('btn-default');
     });
     var color={$js_colors};
     \$(this).removeClass('btn-default');
     \$(this).addClass('btn-'+color[\$(this).data('value')]+' active');
     \$('#{$wid}').val(\$(this).data('value'))
   });  
});               
JS;
        $this->view->registerJs($js);
    }
Пример #2
0
 public function init()
 {
     echo Html::activeHiddenInput($this->model, $this->attribute, $this->options);
     echo Html::error($this->model, $this->attribute, $this->options);
     $id = Html::getInputId($this->model, $this->attribute);
     echo FileInput::widget(['name' => 'file', 'options' => ['accept' => 'image/*', 'multiple' => false], 'pluginEvents' => ['fileuploaded' => 'function(event, data, previewId, index) {
                 $("#' . $id . '").val(data.response.url);
             }'], 'pluginOptions' => ['initialPreview' => $this->model->{$this->attribute} ? [Html::img($this->model->{$this->attribute}, ['class' => 'file-preview-image'])] : false, 'maxFileCount' => 1, 'minFileCount' => 1, 'previewFileType' => 'image', 'multiple' => false, 'showPreview' => true, 'showUploadedThumbs' => false, 'uploadUrl' => \yii\helpers\Url::to(['/system/image/upload'])]]);
     parent::init();
 }
Пример #3
0
    <div class = "y2u-padding">
        <div class="page-header">
            <h3><?php 
echo Yii::t('user', 'Getting Started');
?>
                <small><?php 
echo Yii::t('user', 'Step 1 of 2');
?>
</small>
            </h3>
        </div>
        <?php 
echo $form->field($model, 'access_code')->passwordInput()->hint($hints['access_code']);
?>
        <?php 
echo Html::activeHiddenInput($model, 'action');
?>
    </div>
    <div class="y2u-box-footer">
        <?php 
echo Html::a('<i class="glyphicon glyphicon-question-sign"></i> ' . Yii::t('user', 'Help'), '#help', ['class' => 'btn btn-info pull-left', 'onclick' => '$("#help").slideToggle("slow");']);
?>
        <?php 
echo Html::submitButton(Yii::t('user', 'Proceed') . ' &raquo;', ['class' => 'btn btn-success']);
?>
    </div>
</div>
<?php 
ActiveForm::end();
?>
<br>