public function actionUpload($model, $primaryKey)
 {
     $results = [];
     $modelImage = new Image();
     $modelImage->model = $model;
     $modelImage->primaryKey = $primaryKey;
     if (Yii::$app->request->isPost) {
         $modelImage->file = UploadedFile::getInstance($modelImage, 'file');
         if ($modelImage->file && $modelImage->validate()) {
             /*
             {
                 "name": "picture1.jpg",
                 "size": 902604,
                 "url": "http:\/\/example.org\/files\/picture1.jpg",
                 "thumbnailUrl": "http:\/\/example.org\/files\/thumbnail\/picture1.jpg",
                 "deleteUrl": "http:\/\/example.org\/files\/picture1.jpg",
                 "deleteType": "DELETE"
               },
             */
             $filename = md5($model . $primaryKey . $modelImage->file->name) . '.' . $modelImage->file->extension;
             $modelImage->src = $filename;
             $modelImage->save();
             if ($modelImage->file->saveAs(Yii::getAlias(Image::FILE_DIROOT) . $filename)) {
                 $imagePath = Yii::getAlias(Image::FILE_DIR) . $filename;
                 $result = ['name' => $filename, 'size' => $modelImage->file->size, 'url' => $imagePath, 'thumbnailUrl' => $modelImage->resize(), 'deleteUrl' => Url::to(['/cms/admin/image/delete', 'id' => $modelImage->id]), 'deleteType' => "DELETE"];
                 $results[] = $result;
             }
         } else {
             $results[] = (object) [$modelImage->file->name => false, 'error' => strip_tags(Html::error($modelImage, 'file')), 'extension' => $modelImage->file->extension, 'type' => $modelImage->file->type];
         }
     }
     echo json_encode((object) ['files' => $results]);
 }
Exemple #2
0
 public function actionUpload($model, $primaryKey)
 {
     $results = [];
     $modelImage = new Image();
     $modelImage->model = $model;
     $modelImage->primaryKey = $primaryKey;
     $filePath = $modelImage->getFilePath();
     if (Yii::$app->request->isPost) {
         $modelImage->file = UploadedFile::getInstance($modelImage, 'file');
         if ($modelImage->file && $modelImage->validate()) {
             $filename = $modelImage->file->name;
             $modelImage->src = $filename;
             $modelImage->position = $modelImage->nextPosition;
             $modelImage->save();
             $image = \Yii::$app->image->load($modelImage->file->tempName);
             $image->resize(2592, 1728, \yii\image\drivers\Image::AUTO);
             if ($image->save($filePath . '/' . $filename)) {
                 $imagePath = $filePath . '/' . $filename;
                 $result = ['name' => $filename, 'size' => filesize($filePath . '/' . $filename), 'url' => $imagePath, 'thumbnailUrl' => $modelImage->resize('100x100'), 'deleteUrl' => Url::to(['/core/image/delete', 'id' => $modelImage->id]), 'deleteType' => "DELETE"];
                 $results[] = $result;
             }
         } else {
             $results[] = (object) [$modelImage->file->name => false, 'error' => strip_tags(Html::error($modelImage, 'file')), 'extension' => $modelImage->file->extension, 'type' => $modelImage->file->type];
         }
     }
     echo json_encode((object) ['files' => $results]);
 }
Exemple #3
0
 /**
  * @inheritdoc
  */
 protected function renderFilterCellContent()
 {
     if (is_string($this->filter)) {
         return $this->filter;
     }
     $model = $this->grid->filterModel;
     if ($this->filter !== false && $model instanceof Model && $this->attribute !== null && $model->isAttributeActive($this->attribute)) {
         if ($model->hasErrors($this->attribute)) {
             Html::addCssClass($this->filterOptions, 'has-error');
             $error = ' ' . Html::error($model, $this->attribute, $this->grid->filterErrorOptions);
         } else {
             $error = '';
         }
         if (is_array($this->filter)) {
             $filterItems = $this->filter;
             $filterItems[$this->filterAllValue] = Yii::t('yii2tech-admin', 'All records');
         } else {
             $filterItems = ['0' => Yii::t('yii2tech-admin', 'Deleted'), $this->filterAllValue => Yii::t('yii2tech-admin', 'All records')];
         }
         $options = array_merge(['prompt' => Yii::t('yii2tech-admin', 'Actual only')], $this->filterInputOptions);
         return Html::activeDropDownList($model, $this->attribute, $filterItems, $options) . $error;
     } else {
         return parent::renderFilterCellContent();
     }
 }
Exemple #4
0
 public function render($content = null)
 {
     if ($content === null) {
         if (!isset($this->parts['{input}'])) {
             $this->parts['{input}'] = Html::activeTextInput($this->model, $this->attribute, $this->inputOptions);
         }
         if (!isset($this->parts['{label}'])) {
             $labelsHelp = $this->model->attributeHints();
             if (isset($labelsHelp[$this->attribute])) {
                 $this->labelOptions['label'] = '<span data-toggle="tooltip" title="" data-original-title="';
                 $this->labelOptions['label'] .= Html::encode($labelsHelp[$this->attribute]);
                 $this->labelOptions['label'] .= '">';
                 $this->labelOptions['label'] .= Html::encode($this->model->getAttributeLabel($this->attribute));
                 $this->labelOptions['label'] .= ' <span class="glyphicon glyphicon-question-sign" style="font-size: 8pt;" aria-hidden="true"></span>';
                 $this->labelOptions['label'] .= '</span>';
             } else {
                 $this->labelOptions['label'] = Html::encode($this->model->getAttributeLabel($this->attribute));
             }
             $this->parts['{label}'] = Html::activeLabel($this->model, $this->attribute, $this->labelOptions);
         }
         if (!isset($this->parts['{error}'])) {
             $this->parts['{error}'] = Html::error($this->model, $this->attribute, $this->errorOptions);
         }
         if (!isset($this->parts['{hint}'])) {
             $this->parts['{hint}'] = '';
         }
         $content = strtr($this->template, $this->parts);
     } elseif (!is_string($content)) {
         $content = call_user_func($content, $this);
     }
     return $this->begin() . "\n" . $content . "\n" . $this->end();
 }
Exemple #5
0
 public function render($content = null)
 {
     $this->inputOptions['name'] = '';
     if ($content === null) {
         if (!isset($this->parts['{input}'])) {
             // $this->inputOptions['data-bind'] = sprintf('value: %s', $this->attribute);
             $this->parts['{input}'] = Html::activeTextInput($this->model, $this->attribute, $this->inputOptions);
         }
         if (!isset($this->parts['{hidden}'])) {
             $this->parts['{hidden}'] = Html::activeHiddenInput($this->model, $this->attribute, $this->hiddenOptions);
         }
         if (!isset($this->parts['{label}'])) {
             $this->parts['{label}'] = Html::activeLabel($this->model, $this->attribute, $this->labelOptions);
         }
         if (!isset($this->parts['{error}'])) {
             $this->parts['{error}'] = Html::error($this->model, $this->attribute, $this->errorOptions);
         }
         if (!isset($this->parts['{hint}'])) {
             $this->parts['{hint}'] = '';
         }
         $content = strtr($this->template, $this->parts);
     } elseif (!is_string($content)) {
         $content = call_user_func($content, $this);
     }
     return empty($content) ? '' : ($this->wrapper ? $this->begin() . "\n" . $content . "\n" . $this->end() : $content);
 }
Exemple #6
0
 /**
  * Returns error message if one's exist
  * @return string
  */
 protected function getError()
 {
     if ($this->column->grid->filterModel->hasErrors($this->column->attribute)) {
         Html::addCssClass($this->column->filterOptions, 'has-error');
         return Html::error($this->column->grid->filterModel, $this->column->attribute, $this->column->grid->filterErrorOptions);
     }
     return '';
 }
 /**
  * Renders the input
  *
  * @return string
  */
 protected function renderInput()
 {
     $this->options = array_merge($this->options, ['style' => $this->inputStyle]);
     if (!$this->hideInput) {
         return Html::activeLabel($this->model, $this->attribute, ['class' => 'control-label']) . '<div class="input-group drp-container form-drp-input" style="' . $this->wrapperStyle . '">' . $this->getInput('textInput') . Html::submitButton('<span class="glyphicon glyphicon-floppy-save"></span> ' . \Yii::t('admin', 'Export'), ['class' => 'btn btn-info']) . '</div>' . '<div class="help-block ">' . Html::error($this->model, $this->attribute, ['class' => 'help-block help-block-error']) . '</div>';
     }
     $tag = ArrayHelper::remove($this->containerOptions, 'tag', 'div');
     $content = str_replace('{input}', $this->getInput('hiddenInput'), $this->containerTemplate);
     $content = str_replace('{error}', '<div class="help-block ">' . Html::error($this->model, $this->attribute, ['class' => 'help-block help-block-error']) . '</div>', $content);
     return Html::tag($tag, $content, $this->containerOptions);
 }
 /**
  * @inheritdoc
  */
 protected function renderFilterCellContent()
 {
     if (is_string($this->filter)) {
         return $this->filter;
     }
     $model = $this->grid->filterModel;
     if ($this->filter !== false && $model instanceof Model && $this->attribute !== null && $model->isAttributeActive($this->attribute)) {
         $dateParts = explode('-', $model->{$this->attribute});
         Html::addCssClass($this->btnOptions, 'btn btn-container-open');
         $content = Html::beginTag('div', ['class' => 'column-filter']);
         $content .= Html::beginTag('div', ['class' => 'col-md-12 input-group']);
         $content .= Html::beginTag('span', ['class' => 'input-group-btn']);
         $content .= Html::button('...', $this->btnOptions);
         $content .= Html::endTag('span');
         $content .= Html::activeTextInput($model, $this->attribute, ['class' => 'form-control date-filter-range-input']);
         $content .= Html::endTag('div');
         $content .= Html::beginTag('div', ['class' => 'column-filter-container date-filter-range']);
         $content .= Html::beginTag('div', ['class' => 'row']);
         $content .= Html::beginTag('div', ['class' => 'dateFrom col-md-12']);
         $content .= Html::button($this->labelBtnApply, ['class' => 'btn-apply btn btn-success']);
         $content .= Html::endTag('div');
         $content .= Html::endTag('div');
         $content .= Html::beginTag('div', ['class' => 'row']);
         $content .= Html::beginTag('div', ['class' => 'dateFrom col-md-6']);
         $content .= Html::label($this->labelDateFrom);
         $content .= \kak\widgets\datetimepicker\DateTimePicker::widget(['name' => '', 'value' => isset($dateParts[0]) ? trim($dateParts[0]) : '', 'clientOptions' => $this->clientOptions, 'showInputIcon' => false]);
         $content .= Html::endTag('div');
         $content .= Html::beginTag('div', ['class' => 'dateTo col-md-6']);
         $content .= Html::label($this->labelDateTo);
         $content .= \kak\widgets\datetimepicker\DateTimePicker::widget(['name' => '', 'value' => isset($dateParts[1]) ? trim($dateParts[1]) : '', 'clientOptions' => $this->clientOptions, 'showInputIcon' => false]);
         $content .= Html::endTag('div');
         $content .= Html::endTag('div');
         $content .= Html::endTag('div');
         $content .= Html::endTag('div');
         $error = '';
         if ($model->hasErrors($this->attribute)) {
             $error = ' ' . Html::error($model, $this->attribute, $this->grid->filterErrorOptions);
         }
         /*
         
         if (is_array($this->filter)) {
             $options = array_merge(['prompt' => ''], $this->filterInputOptions);
             return Html::activeDropDownList($model, $this->attribute, $this->filter, $options) . $error;
         } else {
         
         }
         */
         return $content . $error;
     }
     return $this->grid->emptyCell;
     /*parent::renderFilterCellContent();*/
 }
Exemple #9
0
 public function render($content = null)
 {
     if ($content === null) {
         if (!isset($this->parts['{input}'])) {
             $this->parts['{input}'] = Html::activeTextInput($this->model, $this->attribute, $this->inputOptions);
         }
         if (!isset($this->parts['{label}'])) {
             $this->parts['{label}'] = Html::activeLabel($this->model, $this->attribute, $this->labelOptions);
         }
         if (!isset($this->parts['{error}'])) {
             $this->parts['{error}'] = Html::error($this->model, $this->attribute, $this->errorOptions);
         }
         if (!isset($this->parts['{hint}'])) {
             $this->parts['{hint}'] = '';
         }
         $this->parts['{size}'] = $this->size;
         $content = strtr($this->template, $this->parts);
     } elseif (!is_string($content)) {
         $content = call_user_func($content, $this);
     }
     return $this->begin() . "\n" . $content . "\n" . $this->end();
 }
 /**
  * Renders the filter cell content.
  * The default implementation simply renders a space.
  * This method may be overridden to customize the rendering of the filter cell (if any).
  * @return string the rendering result
  */
 protected function renderFilterCellContent()
 {
     if (is_string($this->filter)) {
         return $this->filter;
     }
     $model = $this->grid->filterModel;
     if ($this->filter !== false && $this->attribute !== null && $model->isAttributeActive($this->attribute)) {
         if ($model->hasErrors($this->attribute)) {
             Html::addCssClass($this->filterOptions, 'has-error');
             $error = ' ' . Html::error($model, $this->attribute, $this->grid->filterErrorOptions);
         } else {
             $error = '';
         }
         $filterOptions = ['=' => '=', '>' => '>', '<' => '<'];
         Html::addCssClass($this->filterInputOptions, 'date-filter-input');
         $dropDown = Html::activeDropDownList($model, $this->attribute . '_operand', $filterOptions, ['class' => 'form-control pull-left', 'style' => 'width: 32px; appearance: none; -moz-appearance: none; -webkit-appearance: none;']);
         $field = DatePicker::widget(['model' => $model, 'attribute' => $this->attribute, 'options' => $this->filterInputOptions, 'dateFormat' => 'yyyy-MM-dd']);
         return $dropDown . $field . $error;
     } else {
         return parent::renderFilterCellContent();
     }
 }
 /** @inheritdoc */
 public function render($content = null)
 {
     if ($content === null) {
         if (!isset($this->parts['{input}'])) {
             $this->parts['{input}'] = Html::activeTextInput($this->model, $this->attribute, $this->inputOptions);
         }
         if (!isset($this->parts['{label}'])) {
             $this->parts['{label}'] = Html::activeLabel($this->model, $this->attribute, $this->labelOptions);
         }
         if (!isset($this->parts['{error}'])) {
             $this->parts['{error}'] = Html::error($this->model, $this->attribute, $this->errorOptions);
         }
         if (!isset($this->parts['{hint}'])) {
             $this->parts['{hint}'] = '';
         }
         $containerTag = ArrayHelper::remove($this->containerOptions, 'tag', 'div');
         $this->parts['{input}'] = Html::tag($containerTag, "{$this->parts['{input}']}\n" . ArrayHelper::remove($this->parts, '{error}') . "\n" . ArrayHelper::remove($this->parts, '{hint}'), $this->containerOptions);
         $content = strtr($this->template, $this->parts);
     } elseif (!is_string($content)) {
         $content = call_user_func($content, $this);
     }
     return $this->begin() . "\n" . $content . "\n" . $this->end();
 }
Exemple #12
0
 protected function renderFilterCellContent()
 {
     if (is_string($this->filter)) {
         return $this->filter;
     }
     $model = $this->grid->filterModel;
     if ($this->filter !== false && $this->attribute !== null && $model->isAttributeActive($this->attribute)) {
         if ($model->hasErrors($this->attribute)) {
             Html::addCssClass($this->filterOptions, 'error-state');
             $error = Html::error($model, $this->attribute, $this->grid->filterErrorOptions);
         } else {
             $error = '';
         }
         if (is_array($this->filter)) {
             $options = array_merge(['prompt' => ''], $this->filterInputOptions);
             return Html::beginTag('div', ['class' => 'input-control select']) . Html::activeDropDownList($model, $this->attribute, $this->filter, $options) . ' ' . $error . Html::endTag('div');
         } else {
             return Html::beginTag('div', ['class' => 'input-control text']) . Html::activeTextInput($model, $this->attribute, $this->filterInputOptions) . ' ' . $error . Html::endTag('div');
         }
     } else {
         return parent::renderFilterCellContent();
     }
 }
Exemple #13
0
echo MarkdownEditorFull::widget(['model' => $model, 'attribute' => 'anons', 'showExport' => false]);
?>
        <?php 
echo Html::error($model, 'anons', ['class' => 'text-danger']);
?>
    </div>

    <div class="form-group">
        <?php 
echo Html::activeLabel($model, 'content');
?>
        <?php 
echo MarkdownEditorFull::widget(['model' => $model, 'attribute' => 'content', 'showExport' => false]);
?>
        <?php 
echo Html::error($model, 'content', ['class' => 'text-danger']);
?>
    </div>

    <?php 
echo $form->field($model, 'tags')->listBox(ArrayHelper::map($tags, 'id', 'title'), ['multiple' => true]);
?>

    <?php 
echo $form->field($model, 'category_id')->dropDownList(ArrayHelper::map($category, 'id', 'title'));
?>

    <?php 
echo $form->field($model, 'publish_status')->dropDownList([Post::STATUS_DRAFT => Module::t('module', 'STATUS_DRAFT'), Post::STATUS_PUBLISH => Module::t('module', 'STATUS_PUBLISH'), Post::STATUS_ARCHIVE => Module::t('module', 'STATUS_ARCHIVE')]);
?>
Exemple #14
0
                <?php 
echo DateTimePicker::widget(['model' => $model, 'attribute' => 'next_at', 'type' => DateTimePicker::TYPE_COMPONENT_PREPEND, 'pluginOptions' => ['autoclose' => true]]);
?>
            <?php 
echo Html::error($model, 'next_at', ['data-activity' => 'form-summary', 'class' => 'help-block hidden']);
?>
        </div>
        <div class="col-sm-8"><?php 
echo \Yii::t('net_frenzel_activity', 'Next');
?>
:
            <?php 
echo $form->field($model, 'next_type')->radioButtonGroup($model->NextTypeArray, ['id' => 'next_type-create', 'itemOptions' => ['labelOptions' => ['class' => 'btn btn-primary btn-sm']]])->label(false);
?>
            <?php 
echo Html::error($model, 'next_type', ['data-activity' => 'form-summary', 'class' => 'help-block hidden']);
?>
        </div>    
    </div>

    <div class="row">
        <div class="col-md-12">
            <div class="col-md-9">
                <?php 
$userDesc = empty($model->next_by) ? '' : $model->responsible->username;
$url = \yii\helpers\Url::to(['/activity/default/responsible-list']);
echo $form->field($model, 'next_by')->widget(Select2::classname(), ['initValueText' => $userDesc, 'options' => ['placeholder' => 'responsible ...'], 'pluginOptions' => ['allowClear' => true, 'minimumInputLength' => 3, 'ajax' => ['url' => $url, 'dataType' => 'json', 'data' => new JsExpression('function(params) { return {q:params.term}; }')], 'escapeMarkup' => new JsExpression('function (markup) { return markup; }'), 'templateResult' => new JsExpression('function(user) { return user.text; }'), 'templateSelection' => new JsExpression('function (user) { return user.text; }')]])->label(false);
?>
            </div>
            <div class="col-md-3">
                <?php 
Exemple #15
0
            انتخاب عکس
            <?php 
echo Html::activeFileInput($fileObject, "[{$uniqueId}]resource", ['id' => 'file-input-' . $uniqueId]);
?>
        </span>
        <img
            id="uploaded-image-<?php 
echo $uniqueId;
?>
"
            src="#"
            alt=""
            style="display:none"
            class="thumbnail image-preview" />
        <?php 
echo Html::error($fileObject, 'resource', ['class' => 'help-block']);
?>
    </div>
    <div class="uploaded-images">
        <ul class="list-group">
            <?php 
foreach ($uploadedImages as $image) {
    ?>
                <li class="list-group-item">
                    <div class="image-thumb">
                        <?php 
    echo Html::img($image->getUrl('form-upload'));
    ?>
                        <i
                            class="fa fa-times-circle fa-lg text-danger file-delete"
                            data-id="<?php 
Exemple #16
0
                        <?php 
echo Html::beginForm();
?>
                        <div class="row">
                            <div style="float: left">
                                <?php 
echo Html::activeTextInput($productForm, 'quantity', array('size' => 3, 'maxlength' => 3, 'style' => 'text-align: center'));
?>
                            </div>
                            <div style="float: left; margin-left: 5px">
                                <?php 
echo Html::submitButton('Add to cart', ['id' => 'cart-btn', 'class' => 'btn btn-default btn-block', 'name' => 'cart-button', 'style' => 'background: #ff6666; color: #FFF; border: 1px solid #ff9999; border-radius: 0; font-size: 12px']);
?>
                            </div>
                            <div class="clear"><?php 
echo Html::error($productForm, 'quantity');
?>
</div>
                        </div>
                        <?php 
Html::endForm();
?>
                    </div>
                </div>
                <div class="clearfix"></div>

                <div class="cd-tabs">
                    <ul class="cd-tabs-navigation">
                        <li><a data-toggle="tab" href="#desc" class="selected">Description </a></li>
                        <li><a data-toggle="tab" href="#rev">Reviews (1)</a></li>
                    </ul>
Exemple #17
0
// use checkbox for banned_at
?>
    <?php 
// convert `banned_at` to int so that the checkbox gets set properly
?>
    <?php 
$user->banned_at = $user->banned_at ? 1 : 0;
?>
    <?php 
echo Html::activeLabel($user, 'banned_at', ['label' => Yii::t('user', 'Banned')]);
?>
    <?php 
echo Html::activeCheckbox($user, 'banned_at');
?>
    <?php 
echo Html::error($user, 'banned_at');
?>

    <?php 
echo $form->field($user, 'banned_reason');
?>

    <div class="form-group">
        <?php 
echo Html::submitButton($user->isNewRecord ? Yii::t('user', 'Create') : Yii::t('user', 'Update'), ['class' => $user->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>

    <?php 
ActiveForm::end();
?>
Exemple #18
0
$fieldExtra = '';
if (!empty($model->errors['phone'])) {
    $fieldExtra = 'has-feedback has-error';
}
echo Html::beginTag('div', ['class' => 'col-sm-6 form-group ' . $fieldExtra]);
echo Html::activeLabel($model, 'phone');
echo Html::activeTextInput($model, 'phone', ['class' => 'form-control']);
echo Html::error($model, 'phone', ['class' => 'help-inline text-danger']);
echo Html::endTag('div');
echo Html::endTag('div');
echo Html::beginTag('div', ['class' => 'row']);
$fieldExtra = '';
if (!empty($model->errors['note'])) {
    $fieldExtra = 'has-feedback has-error';
}
echo Html::beginTag('div', ['class' => 'col-sm-6 form-group ' . $fieldExtra]);
echo Html::activeLabel($model, 'note');
echo Html::activeTextArea($model, 'note', ['class' => 'form-control']);
echo Html::error($model, 'note', ['class' => 'help-inline text-danger']);
echo Html::endTag('div');
echo Html::beginTag('div', ['class' => 'col-sm-6']);
echo Html::beginTag('div', ['class' => 'form-group ']);
echo Html::activeCheckbox($model, 'is_technical', []);
echo Html::endTag('div');
echo Html::beginTag('div', ['class' => 'form-group ']);
echo Html::activeCheckbox($model, 'is_billing', []);
echo Html::endTag('div');
echo Html::endTag('div');
echo Html::endTag('div');
echo Html::endTag('div');
echo Html::endForm();
Exemple #19
0
  </div>
    
    <div class="form-group"> 
  <?php 
echo $form->field($model, 'meta_desc')->begin();
?>
    <?php 
echo Html::activeLabel($model, 'meta_desc', ['label' => 'Meta Description']);
?>

          <?php 
echo Html::activeTextInput($model, 'meta_desc', ['class' => 'form-control input-lg', 'placeholder' => 'Meta Description']);
//Field
?>
          <?php 
echo Html::error($model, 'meta_desc', ['id' => 'meta_desc', 'class' => 'help-block help-block-error']);
//error
echo $form->field($model, 'meta_desc')->end();
?>
  </div>
 
  <div class="clearfix"></div>
  <div class="form-group m-t-10 m-b-0">
      <?php 
echo Html::submitButton('Add', ['class' => 'btn btn-primary']);
?>
     <!--<button type="submit" class="btn btn-primary">Add</button>-->
     &nbsp;&nbsp;
     <!--<button type="submit" class="btn btn-default" data-dismiss="modal" aria-label="Close">Cancel</button>-->

  </div> 
Exemple #20
0
                <img src="<?php 
echo Yii::getAlias('@images_url');
?>
/closemodal-icon.png" alt="close"/></button>
            <h4 class="modal-title" id="myModalLabel">Add Categories</h4>
        </div>      
        <div class="modal-body">
              <?php 
$form = ActiveForm::begin(['id' => 'category-form', 'enableAjaxValidation' => false, 'enableClientValidation' => true]);
?>
                <div class="form-group"> 
                    <label>Category Name <span style="color:red"> *</span></label>
                        <?php 
echo Html::activeTextInput($masterCategory, 'category_name', ['class' => 'form-control input-lg', 'placeholder' => '']);
//field
echo Html::error($masterCategory, 'category_name', ['id' => 'category_name', 'class' => 'errorMessage help-block']);
//error
?>
                </div>
                <div class="form-group"> 
                    <?php 
echo $form->field($masterCategory, 'parent_id')->dropDownList(MasterCategory::getcategoryList(), ['class' => 'form-control selectpicker', 'data-live-search' => 'true', 'prompt' => 'None']);
?>
                    
                    
                </div>
                <div class="clearfix"></div>
                <div class="form-group m-t-10 m-b-0">
                    <button type="button" class="btn btn-primary" onclick="saveCategory()">Submit</button>&nbsp;&nbsp;
                    <button type="submit" class="btn btn-default" data-dismiss="modal" aria-label="Close">Cancel</button>
                </div> 
Exemple #21
0
        </div>
        <?php 
}
?>
    </div>
    
    <div class="form-group required">
        <?php 
echo yii\imperavi\Widget::widget(['model' => $model, 'attribute' => 'content', 'options' => ['minHeight' => 300, 'fileUpload' => Url::toRoute(['file-upload', 'attr' => 'content', 'id' => $model->id]), 'imageUpload' => Url::toRoute(['image-upload', 'attr' => 'content', 'id' => $model->id]), 'imageGetJson' => Url::toRoute(['image-list', 'attr' => 'content', 'id' => $model->id]), 'imageUploadErrorCallback' => new \yii\web\JsExpression('function(json) { alert(json.error); }'), 'fileUploadErrorCallback' => new \yii\web\JsExpression('function(json) { alert(json.error); }')]]);
?>
        <?php 
if ($model->hasErrors('content')) {
    ?>
        <div class="has-error">
            <?php 
    echo \yii\helpers\Html::error($model, 'content', $form->field($model, 'content')->errorOptions);
    ?>
        </div>
        <?php 
}
?>
    </div>
    
    <?php 
echo $form->field($model, 'is_active')->checkbox();
?>

    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? Yii::t('modules/post', 'Create') : Yii::t('modules/post', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
				<?php 
echo $form->field($model, 'label')->textArea(array('style' => 'width:99%;height:40px;', 'placeholder' => Module::t('app', 'Empty...')));
?>
				<?php 
echo Html::error($model, 'label');
?>
			</div>
			
			<br>
			
			<div>
				<?php 
echo $form->field($model, 'description')->textArea(array('style' => 'width:99%;', 'placeholder' => Module::t('app', 'Empty...')));
?>
				<?php 
echo Html::error($model, 'description');
?>
			</div>
		</div>
		
		<?php 
// Подвал формы
?>
		
		<div class="ajax-form-footer">
			<table><tr>
				<td style="text-align:right;">
					<button id="urv-form-button-submit" class="ajax-form-button-submit" type="button" style="min-width: 90px;"><?php 
echo Module::t('app', 'Save');
?>
</button>
Exemple #23
0
/**
 * @var yii\web\View $this
 */
use yii\helpers\Html;
?>
<h1>load/index</h1>

<p>
    Yii2

    <?php 
echo Html::beginForm('', 'post', ['enctype' => 'multipart/form-data']);
?>
    <?php 
echo Html::error($upload, 'file');
?>
    <?php 
echo Html::activeFileInput($upload, 'file');
?>
    <?php 
echo Html::submitButton('Upload');
?>
    <?php 
Html::endForm();
?>



</p>
Exemple #24
0
        if (!empty($value['key'])) {
            if ('field' === $value['type']) {
                $_key_list = $feed_settings['product_fields'];
            } elseif ('property' === $value['type']) {
                $_key_list = $feed_settings['properties_map']['fields'];
            } elseif ('relation' === $value['type']) {
                $_key_list = $feed_settings['relations_keys'];
            }
        }
        $input .= '<div class="col-md-6">' . Html::activeDropDownList($field->model, $field->attribute . '[key]', $_key_list, array_merge(['data-ymlselect' => 'key'], $field->inputOptions)) . '</div>';
        $_value_list = [];
        if (!empty($value['value']) && 'relation' === $value['type']) {
            $_value_list = $feed_settings['relations_map'][$value['key']]['fields'];
        }
        $input .= '<div class="col-md-6">' . Html::activeDropDownList($field->model, $field->attribute . '[value]', $_value_list, array_merge(['data-ymlselect' => 'value', 'style' => empty($_value_list) ? 'display:none;' : ''], $field->inputOptions)) . '</div>';
        $error = Html::error($field->model, $field->attribute, $field->errorOptions);
        return sprintf("%s\n<div class=\"col-md-10 offer-group\">%s</div>\n<div class=\"col-md-offset-2 col-md-10\">%s</div>", $label, $input, $error);
    });
}
?>

        <?php 
BackendWidget::end();
?>
    </div>
</div>


<?php 
\kartik\widgets\ActiveForm::end();
?>
Exemple #25
0
<?php 
echo $form->field($model, 'text')->textarea(['rows' => 6]);
?>

<div class="form-group">
    <?php 
echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
</div>

<?php 
ActiveForm::end();
?>

<?php 
echo Html::beginForm(['/post/create2'], 'POST', ['class' => 'form-horizontal', 'data-comment' => 'form', 'data-comment-action' => 'create']);
?>
<div class="form-group" data-comment="form-group">
    <div class="col-sm-12">
        <?php 
echo Html::activeTextarea($model, 'text', ['class' => 'form-control']);
?>
        <?php 
echo Html::error($model, 'content', ['data-comment' => 'form-summary', 'class' => 'help-block hidden']);
?>
    </div>
</div>
<?php 
echo Html::submitButton('submit', ['class' => 'btn btn-danger btn-lg']);
echo Html::endForm();
Exemple #26
0
?>
                <?php 
// convert `ban_time` to int so that the checkbox gets set properly
?>
                <div class="form-group">
                    <?php 
$user->ban_time = $user->ban_time ? 1 : 0;
?>
                    <?php 
// Html::activeCheckbox($user, 'ban_time', ['label' => Yii::t('app', 'Banned') ]);
?>
                    <?php 
echo $form->field($user, 'ban_time')->widget(SwitchInput::classname(), ['pluginEvents' => ["switchChange.bootstrapSwitch" => "function(event, state) {\n                                console.log(event, state);\n                                if( state == true ) {\n                                    \$('#banReason').show();\n                                } else {\n                                    \$('#banReason').hide();\n                                }\n                            }"]])->label(Yii::t('app', 'Banned'));
?>
                    <?php 
echo Html::error($user, 'ban_time');
?>
                </div>
            </div>
            <div class="col-sm-10" id="banReason" style="display: none">
                <?php 
echo $form->field($user, 'ban_reason')->textInput(['placeholder' => Yii::t('app', 'When the user tries to log in,
                    it shows this message.')]);
?>
            </div>
        </div>
    </fieldset>
    <fieldset>
        <legend class="text-primary"><small><?php 
echo Yii::t('app', 'Profile Info');
?>
Exemple #27
0
 /**
  * @inheritdoc
  */
 public static function error($model, $attribute, $options = [])
 {
     $options['tag'] = 'div';
     static::addCssClasses($options, ['ui', 'pointing', 'prompt', 'label', 'transition', 'visible']);
     return parent::error($model, $attribute, $options);
 }
Exemple #28
0
 /**
  * Generates a tag that contains the first validation error of [[attribute]].
  * Note that even if there is no validation error, this method will still return an empty error tag.
  * @param array|boolean $options the tag options in terms of name-value pairs. It will be merged with [[errorOptions]].
  * The options will be rendered as the attributes of the resulting tag. The values will be HTML-encoded
  * using [[Html::encode()]]. If a value is null, the corresponding attribute will not be rendered.
  *
  * The following options are specially handled:
  *
  * - tag: this specifies the tag name. If not set, "div" will be used.
  *
  * If this parameter is false, no error tag will be rendered.
  *
  * @return static the field object itself
  */
 public function error($options = [])
 {
     if ($options === false) {
         $this->parts['{error}'] = '';
         return $this;
     }
     $options = array_merge($this->errorOptions, $options);
     $this->parts['{error}'] = Html::error($this->model, $this->attribute, $options);
     return $this;
 }
Exemple #29
-1
 /**
  * @inheritdoc
  */
 protected function renderFilterCellContent()
 {
     if ($this->format == 'boolean') {
         $this->filter = [\Yii::t('app', 'No'), \Yii::t('app', 'Yes')];
     }
     if (is_string($this->filter)) {
         return $this->filter;
     }
     $model = $this->grid->filterModel;
     if ($this->filter !== false && $model instanceof Model && $this->attribute !== null && $model->isAttributeActive($this->attribute)) {
         if ($model->hasErrors($this->attribute)) {
             Html::addCssClass($this->filterOptions, 'has-error');
             $error = ' ' . Html::error($model, $this->attribute, $this->grid->filterErrorOptions);
         } else {
             $error = '';
         }
         if (is_array($this->filter)) {
             $options = array_merge(['prompt' => ''], $this->filterInputOptions);
             return Html::activeDropDownList($model, $this->attribute, $this->filter, $options) . $error;
         } else {
             return Html::activeTextInput($model, $this->attribute, $this->filterInputOptions) . $error;
         }
     } else {
         return parent::renderFilterCellContent();
     }
 }
Exemple #30
-1
 protected function renderFilterCellContent()
 {
     if (is_string($this->filter)) {
         return $this->filter;
     }
     $model = $this->grid->filterModel;
     if ($this->filter !== false && $model instanceof Model && $this->attribute !== null && $model->isAttributeActive($this->attribute)) {
         if ($model->hasErrors($this->attribute)) {
             $error = Html::error($model, $this->attribute, $this->grid->filterErrorOptions);
         } else {
             $error = '';
         }
         if (is_array($this->filter)) {
             $options = array_merge(['prompt' => ''], $this->filterDropdownOptions);
             if ($model->hasErrors($this->attribute)) {
                 Html::addCssClass($options, 'error');
             }
             return Select::widget(['model' => $model, 'attribute' => $this->attribute, 'items' => $this->filter, 'options' => $options, 'search' => true]) . ' ' . $error;
         } else {
             $options = ['class' => 'fluid'];
             if ($model->hasErrors($this->attribute)) {
                 Html::addCssClass($options, 'error');
             }
             return Elements::input(Html::activeTextInput($model, $this->attribute, $this->filterInputOptions) . $error, $options);
         }
     } else {
         return parent::renderFilterCellContent();
     }
 }