123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- <?php
- use yii\helpers\Html;
- use yii\widgets\ActiveForm;
- use kartik\datetime\DateTimePicker;
- use app\widgets\CropperjsWidget;
- $form = ActiveForm::begin([
- 'id' => 'inquirer-form',
- 'options' => ['class' => 'form-horizontal', 'enctype' => 'multipart/form-data']]);
- ?>
- <input type="hidden" name="inquirer[id]" value="<?=$model->id?>">
- <div class="container-fluid">
- <div class="row">
- <div class="col">
- <?
- echo $form->field($model, 'text')->textInput([
- 'maxlength' => true,
- 'class' => 'form-control js-word-count-input',
- 'placeholder' => 'Вопрос',
- // 'id' => 'js-news-content'
- ])->label('Вопрос');
- ?>
- <div class="card">
- <div class="card-header">
- <h3 class="card-title">Варианты ответов</h3>
- </div>
- <div class="card-body">
- <?
- $answers = $model->getAnswers();
- foreach($answers as $item){
- ?>
- <div class="info-box answer">
- <span class="info-box-icon bg-info"><i class="far fa-thumbs-up"></i><br><span class="info-box-number-cnt"><?=$item->count?></span></span>
- <div class="info-box-content">
- <div class="input-group">
- <input type="text" class="form-control" value="<?=$item->text?>" name="Inquirer[text_answer][<?=$item->id?>]">
- <div class="input-group-append">
- <span class="btn btn-dark btn-flat" onclick="remove(this)"><b>-</b></span>
- </div>
- </div>
- </div>
- </div>
- <?
- }
- ?>
- </div>
- <div class="card-footer">
- <div class="card-tools">
- <button type="button" class="btn btn-outline-primary" onclick="addanswer()"><b>+</b></button>
- </div>
- </div>
- </div>
- <div class="form-group form-check">
- <?
- //($model->show == 'Y')?true:false,
- echo $form->field($model, 'show')->checkbox([
- 'class' => 'form-check-input',
- 'label' => 'Включить голосование',
- 'uncheck' => 'N',
- 'value' => 'Y',
- 'checked' => ($model->show == 'Y')?true:false
- ]);
- echo $form->field($model, 'active')->checkbox([
- 'class' => 'form-check-input',
- 'label' => 'Показывать',
- 'uncheck' => 'N',
- 'value' => 'Y',
- 'checked' => ($model->active == 'Y')?true:false
- ]);
- ?>
- </div>
- <div class="form-group">
- <?
- echo Html::submitButton('Сохранить', ['class' => 'btn btn-success']);
- ?>
- </div>
- </div>
- </div>
- </div>
- <script id="template-answer" type="text/template">
- <div class="info-box answer">
- <span class="info-box-icon bg-info"><i class="far fa-thumbs-up"></i></span>
- <div class="info-box-content">
- <div class="input-group">
- <input type="text" class="form-control" value="" name="Inquirer[text_new][]">
- <div class="input-group-append">
- <span class="btn btn-dark btn-flat" onclick="remove(this)"><b>-</b></span>
- </div>
- </div>
- </div>
- </div>
- </script>
- <script>
- function addanswer(){
- el = document.getElementById('template-answer').innerHTML,
- $(el).appendTo($('.card-body'));
- }
- function remove(el){
- $(el).parent().closest('.answer').remove();
- }
- </script>
- <style>
- .info-box-number-cnt{
- position: absolute;
- bottom: 6px;
- font-size: 17px;
- }
- </style>
- <?
- ActiveForm::end();
|