Esempio n. 1
4
 /**
  * @inheritdoc
  */
 public function run()
 {
     $jsOptions = ['clientOptions' => $this->clientOptions];
     $this->options['id'] = 'input-id';
     if ($this->hasModel()) {
         echo Html::activeInput('file', $this->model, $this->attribute, $this->options);
         echo Html::img('#', ['id' => 'cropper-box']);
         echo Html::button('Crop', ['id' => 'cropImage']);
         $input_name = Html::getInputName($this->model, $this->attribute);
         $input_id = Html::getInputId($this->model, $this->attribute);
         echo Html::hiddenInput($input_name . '[file]', '', ['id' => $input_id . '_image']);
         $jsOptions['model'] = $this->model;
         $jsOptions['attribute'] = $this->attribute;
     } else {
         echo Html::fileInput($this->name, $this->value, $this->options);
         echo Html::img('#', ['id' => 'cropper-box']);
         echo Html::button('Crop', ['id' => 'cropImage']);
     }
     if ($this->uploadUrl) {
         $this->uploadUrl = \Yii::getAlias($this->uploadUrl);
     }
     $jsOptions['uploadUrl'] = $this->uploadUrl;
     $jsOptions['uploadCroppedUrl'] = $this->uploadCroppedUrl;
     $jsOptions['changeUrl'] = $this->changeUrl;
     $jsOptions['name'] = $this->name;
     $jsOptions['aspectRatio'] = $this->aspectRatio;
     $this->registerPlugin($jsOptions);
 }
Esempio n. 2
2
 public function init()
 {
     $this->id = $this->hasModel() ? Html::getInputId($this->model, $this->attribute) : $this->id;
     $this->_options = ['serverUrl' => Url::to(['upload']), 'initialFrameWidth' => '100%', 'initialFrameHeight' => '300', 'lang' => strtolower(Yii::$app->language) == 'en-us' ? 'en' : 'zh-cn'];
     $this->clientOptions = ArrayHelper::merge($this->_options, $this->clientOptions);
     parent::init();
 }
 public function renderFileContent()
 {
     $attribute = $this->attribute;
     $input = $thumb = '';
     $selectedFileOpt = ['class' => 'fm-browse-input'];
     if ($this->model->{$attribute}) {
         $filesModel = \Yii::$app->getModule('filemanager')->models['files'];
         $file = $filesModel::findOne(['file_identifier' => $this->model->{$attribute}]);
     }
     if (isset($file) && $file) {
         $fileType = $file->mime_type;
         if ($file->dimension) {
             $src = $file->object_url . $file->thumbnail_name;
             $fileType = 'image';
         } else {
             $src = $file->object_url . $file->src_file_name;
         }
         $gridBox = new \dpodium\filemanager\components\GridBox(['owner' => $this, 'src' => $src, 'fileType' => $fileType, 'toolArray' => [['tagType' => 'i', 'options' => ['class' => 'fa-icon fa fa-times fm-remove', 'title' => Yii::t('filemanager', 'Remove')]]], 'thumbnailSize' => \Yii::$app->getModule('filemanager')->thumbnailSize]);
         foreach ($this->fileData as $attribute) {
             $value = isset($file->{$attribute}) ? $file->{$attribute} : null;
             $input .= Html::input('input', "Filemanager[{$attribute}]", $value);
         }
         $thumb = $gridBox->renderGridBox();
     } else {
         $selectedFileOpt['value'] = '';
     }
     $fileView = Html::tag('div', $thumb, ['class' => 'fm-browse-selected-view']);
     $selectedFile = Html::activeInput('input', $this->model, $this->attribute, $selectedFileOpt);
     $buttonClass = empty($this->options['class']) ? 'btn btn-primary' : $this->options['class'];
     $browseButton = Html::label(Yii::t('filemanager', 'Browse'), Html::getInputId($this->model, $this->attribute), ['class' => 'fm-btn-browse btn-browse ' . $buttonClass, 'data-url' => Url::to(['/filemanager/files/browse']), 'data-backdrop' => 'static', 'data-toggle' => 'modal', 'data-target' => '#fm-modal']);
     return $fileView . $browseButton . $selectedFile . $input;
 }
 public function run()
 {
     if ($this->model === null) {
         $inputId = $this->getId();
     } else {
         if ($this->getId(false) === null) {
             $inputId = Html::getInputId($this->model, $this->attribute);
             $this->setId($inputId);
         } else {
             $inputId = $this->getId();
         }
     }
     $widgetId = $inputId . '-map';
     if ($this->name === null) {
         $inputName = $this->model === null ? null : Html::getInputName($this->model, $this->attribute);
     } else {
         $inputName = $this->name;
     }
     if ($this->enableSearchBox === true) {
         $this->_renderSearchBox();
     }
     // render attribute as hidden input
     if ($this->model === null) {
         echo Html::hiddenInput($inputName, $this->value, ['id' => $inputId, 'name' => $inputName]);
     } else {
         echo Html::activeHiddenInput($this->model, $this->attribute, ['id' => $inputId, 'name' => $inputName]);
     }
     $this->_registerOnChangedEvent($this->id);
     $this->_registerOnInitializedEvent();
     $this->_setClientLocation();
     $widgetOptions = $this->options;
     unset($widgetOptions['id']);
     echo LocationPickerWidget::widget(['id' => $widgetId, 'key' => $this->key, 'options' => $widgetOptions, 'clientOptions' => $this->clientOptions, 'clientEvents' => $this->clientEvents]);
 }
 public function actionValidateadd()
 {
     if (Yii::$app->request->get('type') == 'out') {
         $model = new OutRecord();
     } else {
         $model = new InRecord();
     }
     Yii::$app->response->format = yii\web\Response::FORMAT_JSON;
     if ($model->load(Yii::$app->request->post())) {
         $member = Member::isExist($model->membername);
         $result = yii\widgets\ActiveForm::validate($model);
         if (!$member) {
             $model->addError('membername', '用户编号不存在,请确认后输入');
         } else {
             if (Yii::$app->request->get('type') == 'out') {
                 if ($model->account_type == 1) {
                     $compareData = $member->finance_fund;
                 } else {
                     $compareData = $member->stack_fund;
                 }
                 if ($model->amount > $compareData) {
                     $model->addError('amount', '账户余额不足,理财账户余额: ' . $member->finance_fund . '. 购股账户余额: ' . $member->stack_fund);
                 }
             }
         }
         foreach ($model->getErrors() as $attribute => $errors) {
             $result[yii\helpers\Html::getInputId($model, $attribute)] = $errors;
         }
         echo json_encode($result);
     } else {
         echo json_encode(array());
     }
     Yii::$app->end();
 }
Esempio n. 6
1
 /**
  * Initializes the widget.
  * If you override this method, make sure you call the parent implementation first.
  */
 public function init()
 {
     if ($this->hasModel() && !isset($this->options['id'])) {
         $this->options['id'] = Html::getInputId($this->model, $this->attribute);
     }
     parent::init();
 }
Esempio n. 7
0
 public function init()
 {
     $id = $this->getId();
     $buttonId = 'fm-btn-' . $id;
     $this->fileManager = ArrayHelper::merge(['controller' => Adm::getInstance()->id . '/elfinder', 'filter' => 'image', 'template' => '<div class="input-group fm-input-cont"><span class="input-group-addon">{button}</span>{input}</div>', 'options' => ['class' => 'form-control'], 'buttonTag' => 'a', 'buttonName' => '', 'buttonOptions' => ['class' => 'glyphicon glyphicon-folder-open filemanager-btn', 'href' => 'javascript:void(0);', 'id' => $buttonId, 'data' => ['placement' => 'top']], 'multiple' => true], $this->fileManager);
     if ($this->enablePreview) {
         $basePath = Yii::getAlias($this->basePath);
         $this->getView()->registerJs('
         $("#' . $buttonId . '").tooltip({
             html: true,
             title: function(){
                 var v = $(this).closest(".fm-input-cont").find("#' . Html::getInputId($this->model, $this->attribute) . '").val();
                 var $img = $("<img src=\\"' . $basePath . '" + v + "\\" class=\\"hide file-input-img\\">");
                 var $loading = $("<span class=\\"file-input-loading fa fa-spinner rotating\\"></span>");
                 $img.on("load", function(){
                     $img.removeClass("hide");
                     $loading.hide();
                 })
                 return $("<div class=\\"file-input-cont\\"><div>").append($loading).append($img);
             },
         });
     ');
     }
     parent::init();
 }
Esempio n. 8
0
 /**
  * @inheritdoc
  */
 public function run()
 {
     $this->clientOptions = array_merge_recursive(self::$defaultSettings, $this->clientOptions);
     $this->clientOptions['extended_valid_elements'] = implode(',', $this->clientOptions['extended_valid_elements']);
     if ($this->hasModel()) {
         $this->options['name'] = isset($this->options['name']) ? $this->options['name'] : Html::getInputName($this->model, $this->attribute);
         if (isset($this->options['value'])) {
             $value = $this->options['value'];
             unset($this->options['value']);
         } else {
             $value = Html::getAttributeValue($this->model, $this->attribute);
         }
         if (!array_key_exists('id', $this->options)) {
             $this->options['id'] = Html::getInputId($this->model, $this->attribute);
         }
     } else {
         $options['name'] = $this->name;
         $value = $this->value;
     }
     if (!isset($this->options['class'])) {
         $this->options['class'] = 'tinymce';
     }
     echo Html::tag('div', $value, $this->options);
     $this->registerClientScript();
 }
Esempio n. 9
0
 public function init()
 {
     $this->id = $this->hasModel() ? Html::getInputId($this->model, $this->attribute) : $this->id;
     $this->_options = ['serverUrl' => Url::to(['upload']), 'initialFrameWidth' => '100%', 'initialFrameHeight' => '400', 'toolbars' => [['fullscreen', 'source', 'undo', 'redo', 'removeformat', 'lineheight', 'indent', 'simpleupload']], 'lang' => strtolower(Yii::$app->language) == 'en-us' ? 'en' : 'zh-cn'];
     $this->clientConfig = count($this->clientConfig) > 0 ? ArrayHelper::merge($this->_options, $this->clientConfig) : $this->_options;
     parent::init();
 }
Esempio n. 10
0
 public function init()
 {
     $this->id = $this->hasModel() ? Html::getInputId($this->model, $this->attribute) : $this->id;
     $this->_init = ['serverUrl' => Url::to(['upload']), 'lang' => strtolower(\Yii::$app->language) == 'en-us' ? 'en' : 'zh-cn'];
     $this->options = ArrayHelper::merge($this->_init, $this->options);
     //parent::init();
 }
Esempio n. 11
0
 public function run()
 {
     if (!$this->hasModel() || !$this->attribute) {
         throw new InvalidConfigException('Fuzzydate DatePicker must have model and attribute.');
     }
     $view = $this->getView();
     $asset = new DatePickerAsset();
     $asset->register($view);
     $view->registerJs("fuzzyReg();");
     $id = Html::getInputId($this->model, $this->attribute);
     $val = Html::getAttributeValue($this->model, $this->attribute);
     if ($val && is_array($val)) {
         $y = $val['y'];
         if ($y) {
             $m = $val['m'];
             if (!$m) {
                 $m = 'null';
             }
             $d = $val['d'];
             if (!$d) {
                 $d = 'null';
             }
             // Call this after initializing jQuery-objects
             $view->registerJs("fuzzySet('{$id}', {$y}, {$m}, {$d});", View::POS_LOAD);
         }
     }
     if (!$this->minYear) {
         $this->minYear = date('Y');
     }
     if (!$this->maxYear) {
         $this->maxYear = date('Y');
     }
     $widget = $this->getViewPath() . DIRECTORY_SEPARATOR . 'datePicker.php';
     echo $view->renderFile($widget, ['widget' => $this]);
 }
Esempio n. 12
0
 /**
  * Initializes the widget.
  */
 public function init()
 {
     parent::init();
     if (empty($this->id)) {
         $this->id = $this->hasModel() ? Html::getInputId($this->model, $this->attribute) : $this->getId();
     }
     if (empty($this->name)) {
         $this->name = $this->hasModel() ? Html::getInputName($this->model, $this->attribute) : $this->id;
     }
     if (empty($this->value) && $this->hasModel() && $this->model->hasAttribute($this->attribute)) {
         $this->value = $this->model->getAttribute($this->attribute);
     }
     if (!$this->autoHeightEnable) {
         if (empty($this->width)) {
             $this->width = '100%';
         }
         if (empty($this->height)) {
             $this->height = '350';
         }
     }
     $options = ['id' => $this->id, 'style' => 'width:100%;height:350px'];
     $this->options = array_merge($options, $this->options);
     $jsOptions = ['serverUrl' => Url::to(['ueditor', 'type' => 'ueditor']), 'autoHeightEnable' => $this->autoHeightEnable, 'autoFloatEnable' => true, 'textarea' => $this->name];
     $this->jsOptions = array_merge($jsOptions, $this->jsOptions);
 }
Esempio n. 13
0
 private function renderDropDownList($data, $value = null)
 {
     if (!count($data)) {
         return;
     }
     return Select2::widget(['id' => md5(Html::getInputId($this->model, $this->attribute) . mt_rand(0, 999999999) . mt_rand(0, 999999999)), 'name' => '', 'value' => $value, 'data' => array_merge([0 => '...'], $data), 'language' => 'ru']);
 }
Esempio n. 14
0
 /**
  * @inheritdoc
  */
 public function run()
 {
     if ($this->hasModel()) {
         $name = Html::getInputName($this->model, $this->attribute);
         $value = null;
         if (is_array($this->model->{$this->attribute})) {
             $value = StringHelper::base64EncodeUrl(serialize((array) $this->model->{$this->attribute}));
         } else {
             if (is_string($this->model->{$this->attribute})) {
                 $value = $this->model->{$this->attribute};
             }
         }
         $this->options['id'] = Html::getInputId($this->model, $this->attribute);
         //$element = Html::activeHiddenInput($this->model, $this->attribute, $this->options);
         $element = Html::hiddenInput($name, $value, $this->options);
     } else {
         $element = Html::hiddenInput($this->name, $this->value, $this->options);
     }
     $this->registerPlugin();
     $this->clientOptions['componentSelectId'] = $this->componentSelectId;
     $this->clientOptions['componentSettingsId'] = Html::getInputId($this->model, $this->attribute);
     $this->clientOptions['id'] = $this->id;
     $this->clientOptions['backend'] = UrlHelper::construct('/cms/admin-universal-component-settings/index')->setSystemParam(Module::SYSTEM_QUERY_EMPTY_LAYOUT, 'true')->enableAdmin()->toString();
     return $this->render('element', ['widget' => $this, 'element' => $element]);
 }
Esempio n. 15
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     if ($this->name === null && !$this->hasModel() && $this->selector === null) {
         throw new InvalidConfigException("Either 'name', or 'model' and 'attribute' properties must be specified.");
     }
     if (!isset($this->options['id'])) {
         $this->options['id'] = $this->hasModel() ? Html::getInputId($this->model, $this->attribute) : $this->getId();
     }
     if (!empty($this->defaultSettings)) {
         $this->settings = ArrayHelper::merge($this->defaultSettings, $this->settings);
     }
     if (isset($this->settings['plugins']) && (!is_array($this->settings['plugins']) || !is_array($this->plugins))) {
         throw new InvalidConfigException('The "plugins" property must be an array.');
     }
     if (!isset($this->settings['lang']) && Yii::$app->language !== 'en-US') {
         $this->settings['lang'] = substr(Yii::$app->language, 0, 2);
     }
     if ($this->selector === null) {
         $this->selector = '#' . $this->options['id'];
     } else {
         $this->_renderTextarea = false;
     }
     // @codeCoverageIgnoreStart
     $request = Yii::$app->getRequest();
     if ($request->enableCsrfValidation) {
         $this->settings['uploadImageFields'][$request->csrfParam] = $request->getCsrfToken();
         $this->settings['uploadFileFields'][$request->csrfParam] = $request->getCsrfToken();
     }
     // @codeCoverageIgnoreEnd
     parent::init();
 }
Esempio n. 16
0
 public function init()
 {
     parent::init();
     if (!isset($this->options['id'])) {
         $this->options['id'] = $this->hasModel() ? Html::getInputId($this->model, $this->attribute) : $this->getId();
     }
 }
Esempio n. 17
0
 public function actionValidatebuy()
 {
     $model = new StackTransaction();
     $stack = Stack::findOne(Yii::$app->request->get('id'));
     if ($model->load(Yii::$app->request->post())) {
         $data = Yii::$app->request->post();
         $result = ActiveForm::validate($model);
         $model->price = $stack->price;
         $model->member_id = Yii::$app->user->identity->id;
         $model->stack_id = $stack->id;
         $model->type = 0;
         $model->total_price = $model->price * $model->volume;
         if ($data['StackTransaction']['password2'] && Yii::$app->user->identity->validatePassword2($data['StackTransaction']['password2'])) {
             $model->addError('password2', '第二密码不正确, 请确认后重新输入.');
         }
         if ($model->account_type == 1 && Yii::$app->user->identity->finance_fund < $model->total_price || $model->account_type == 2 && Yii::$app->user->identity->stack_fund < $model->total_price) {
             if (Yii::$app->user->identity->finance_fund < $model->total_price) {
                 $model->addError('volume', '账户余额不足. 理财基金:.' . Yii::$app->user->identity->finance_fund . '. 购股账户:' . Yii::$app->user->identity->stack_fund);
             }
         }
         foreach ($model->getErrors() as $attribute => $errors) {
             $result[Html::getInputId($model, $attribute)] = $errors;
         }
         Yii::$app->response->format = Response::FORMAT_JSON;
         echo json_encode(ActiveForm::validate($model));
     } else {
         echo json_encode(array());
     }
     Yii::$app->end();
 }
Esempio n. 18
0
 public function init()
 {
     parent::init();
     $clientValue = self::toClientFormat($this->model->{$this->attribute});
     if ($clientValue === false) {
         throw new InvalidConfigException();
     }
     $this->model->{$this->attribute} = $clientValue;
     if (!isset($this->select2Config['pluginOptions']['allowClear'])) {
         $this->select2Config['pluginOptions']['placeholder'] = '';
         $this->select2Config['pluginOptions']['allowClear'] = true;
     }
     if (!isset($this->select2Config['options'])) {
         $this->select2Config['options'] = null;
     }
     $this->setDataTarget($this->select2Config['options']);
     Html::addCssClass($this->select2Config['options'], 'combowidget-select2');
     if (!isset($this->select2Config['value'])) {
         $this->select2Config['value'] = $this->inputValue(self::STATE_LIST);
     }
     // ugly workaround (InputWidget must have name or model)
     $this->select2Config['name'] = Html::getInputId($this->model, $this->attribute) . '-ignored-combowidget-select2';
     $this->setDataTarget($this->switchOptions);
     Html::addCssClass($this->switchOptions, 'combowidget-switch');
     $this->setDataTarget($this->textInputOptions);
     Html::addCssClass($this->textInputOptions, 'combowidget-textinput');
 }
Esempio n. 19
0
 /**
  * @throws \yii\base\InvalidConfigException
  */
 public function init()
 {
     $this->id = $this->hasModel() ? Html::getInputId($this->model, $this->attribute) : $this->id;
     $this->_options = ['fileManagerJson' => Url::to(['Kupload', 'action' => 'fileManagerJson']), 'uploadJson' => Url::to(['Kupload', 'action' => 'uploadJson']), 'width' => '100%', 'height' => '400'];
     $this->clientOptions = ArrayHelper::merge($this->_options, $this->clientOptions);
     parent::init();
 }
Esempio n. 20
0
 public function init()
 {
     $value = $this->model->{$this->attribute};
     if (is_int($value) || is_float($value) || is_string($value) && strlen($value)) {
         $this->inputOptions['value'] = Text::date($this->dateFormat . $this->separator . $this->timeFormat, $value);
         $this->hiddenInputOptions['value'] = Text::date($this->altDateFormat . $this->altSeparator . $this->altTimeFormat, $value);
     }
     if (!$this->readOnly) {
         $pluginOptions = array_merge(['numberOfMonths' => 3, 'showButtonPanel' => true, 'altFieldTimeOnly' => false], $this->pluginOptions, ['dateFormat' => Text::juiDateFormat($this->dateFormat), 'altFormat' => Text::juiDateFormat($this->altDateFormat), 'separator' => $this->separator, 'altSeparator' => $this->altSeparator, 'timeFormat' => Text::juiTimeFormat($this->timeFormat), 'altTimeFormat' => Text::juiTimeFormat($this->altTimeFormat)]);
         $inputId = Html::getInputId($this->model, $this->attribute);
         $pluginOptions['altField'] = '#' . $inputId . '-alt';
         $js = 'jQuery(\'#' . $inputId . '\').datetimepicker(' . Json::encode($pluginOptions) . ');';
         $this->inputOptions['name'] = false;
         $this->hiddenInputOptions['id'] = $inputId . '-alt';
         $this->template .= "\n{hiddenInput}";
         $this->parts['{hiddenInput}'] = Html::activeHiddenInput($this->model, $this->attribute, $this->hiddenInputOptions);
         if (Yii::$app->getRequest()->getIsAjax()) {
             $this->template .= "\n{script}";
             $this->parts['{script}'] = Html::script($js);
         } else {
             $view = $this->form->getView();
             TimePickerAsset::register($view);
             $view->registerJs($js);
         }
     }
     parent::init();
 }
Esempio n. 21
0
 public function run()
 {
     if ($this->hasModel()) {
         $replace['{input}'] = Html::activeHiddenInput($this->model, $this->attribute, $this->options);
         $attributeId = Html::getInputId($this->model, $this->attribute);
         $id = Html::getInputId($this->model, 'hydra_' . $this->attribute);
         $name = Html::getInputName($this->model, 'hydra_' . $this->attribute);
         $this->value = $this->model[$this->attribute];
     } else {
         $replace['{input}'] = Html::hiddenInput($this->name, $this->value, $this->options);
         $name = $id = 'hydra_' . $this->name;
         $attributeId = $this->name;
     }
     $fileInputName = empty($this->fileInputName) ? $name : $this->fileInputName;
     $replace['{preview}'] = 'Файл еще не загружен';
     if (!empty($this->value)) {
         $replace['{preview}'] = $this->value;
         $extension = Yii::$app->hydra->getExtension($this->value);
         if (Yii::$app->hydra->isImage($extension)) {
             $replace['{preview}'] = Html::img(Yii::$app->hydra->getCacheUrl($this->value, $this->resolution), ['id' => $id . '_image']);
         }
         $replace['{reset-button}'] = Html::tag($this->resetButton['tag'], $this->resetButton['label'], ArrayHelper::merge(['onClick' => '$("#' . $attributeId . '").val("");$("#' . $id . '_image' . '").remove();$(this).remove();'], $this->resetButton['options']));
     }
     $replace['{input}'] .= Html::fileInput($fileInputName, null, ArrayHelper::merge(['id' => $id], $this->fileInput['options']));
     return strtr($this->template, $replace);
 }
Esempio n. 22
0
 protected function registerScript($options = [])
 {
     $configure = !empty($options) ? Json::encode($options) : '';
     if (!isset($options['id'])) {
         $options['id'] = Html::getInputId($this->model, $this->attribute);
     }
     $this->form->getView()->registerJs("jQuery('#{$options['id']}').pickadate({$configure});");
 }
 public function init()
 {
     parent::init();
     if (!isset($this->inputId)) {
         $this->inputId = isset($this->model) ? Html::getInputId($this->model, $this->attribute) : $this->getId() . '-input';
         $this->inputName = isset($this->model) ? Html::getInputName($this->model, $this->attribute) : $this->getId() . '-name';
     }
 }
Esempio n. 24
0
 /**
  * Registers the required JavaScript.
  */
 public function registerClientScript()
 {
     $view = $this->getView();
     DualListboxAsset::register($view);
     $id = array_key_exists('id', $this->options) ? $this->options['id'] : Html::getInputId($this->model, $this->attribute);
     $options = empty($this->clientOptions) ? '' : Json::encode($this->clientOptions);
     $view->registerJs("jQuery('#{$id}').bootstrapDualListbox({$options});");
 }
Esempio n. 25
0
 /**
  * @throws \yii\base\InvalidConfigException
  */
 public function init()
 {
     $this->id = $this->hasModel() ? Html::getInputId($this->model, $this->attribute) : $this->id;
     // 默认配置
     $options = ['serverUrl' => Url::to(['ueditor']), 'initialFrameWidth' => '100%', 'initialFrameHeight' => '400', 'lang' => strtolower(Yii::$app->language)];
     $this->clientOptions = ArrayHelper::merge($options, $this->clientOptions);
     parent::init();
 }
Esempio n. 26
0
 /**
  * Получение ошибок валидации в нужном формате для отобржения
  * на клиенте
  * @return array
  */
 public function getFormattedError()
 {
     $result = [];
     foreach ($this->owner->getErrors() as $attribute => $errors) {
         $result[Html::getInputId($this->owner, $attribute)] = $errors;
     }
     return $result;
 }
Esempio n. 27
0
 public function run()
 {
     $inputId = Html::getInputId($this->model, $this->attribute);
     $dropzoneId = $inputId . '-dropzone-widget';
     $out = Html::activeHiddenInput($this->model, $this->attribute);
     $out .= Html::tag('div', '', ['id' => $dropzoneId, 'class' => 'dropzone ' . (isset($this->options['class']) ? $this->options['class'] : '')]);
     $this->registerJs($inputId, $dropzoneId);
     return $out;
 }
Esempio n. 28
0
 public function mergeInputOptions($config = [], $options = [])
 {
     $options = ArrayHelper::merge($this->inputOptions, $config, $options);
     if (!array_key_exists('id', $options)) {
         $options['id'] = Html::getInputId($this->model, $this->attribute);
     }
     $this->adjustLabelFor($options);
     return $options;
 }
Esempio n. 29
-1
 /**
  * @see \yii\widgets\ActiveField::begin()
  */
 public function begin()
 {
     if ($this->form->enableClientScript) {
         $clientOptions = $this->getClientOptions();
         if (!empty($clientOptions)) {
             $this->form->attributes[] = $clientOptions;
         }
     }
     $inputID = Html::getInputId($this->model, $this->attribute);
     $attribute = Html::getAttributeName($this->attribute);
     $options = $this->options;
     $class = isset($options['class']) ? [$options['class']] : [];
     $class[] = "field-{$inputID}";
     if ($this->model->isAttributeRequired($attribute)) {
         $class[] = $this->form->requiredCssClass;
     }
     if ($this->model->hasErrors($attribute)) {
         $class[] = $this->form->errorCssClass;
     }
     $options['class'] = implode(' ', $class);
     $tag = ArrayHelper::getValue($this->options, 'tag', 'div');
     //$tag = isset($this->options['tag']) ? $this->options['tag'] : 'div';
     if ($tag) {
         return Html::beginTag($tag, $options);
     }
 }
Esempio n. 30
-1
 public function init()
 {
     if ($this->name === null && !$this->hasModel() && $this->selector === null) {
         throw new InvalidConfigException("Either 'name', or 'model' and 'attribute' properties must be specified.");
     }
     if (null === $this->schema) {
         throw new InvalidConfigException("You must specify 'schema' property.");
     }
     if ($this->hasModel() && !isset($this->options['id'])) {
         $this->options['id'] = Html::getInputId($this->model, $this->attribute);
     }
     if ($this->hasModel()) {
         $this->name = empty($this->options['name']) ? Html::getInputName($this->model, $this->attribute) : $this->options['name'];
         $this->value = Html::getAttributeValue($this->model, $this->attribute);
     }
     if (!isset($this->containerOptions['id'])) {
         $this->containerOptions['id'] = ($this->hasModel() ? Html::getInputId($this->model, $this->attribute) : $this->getId()) . '-container';
     }
     if ($this->inputId === null) {
         $this->inputId = $this->options['id'];
     } else {
         $this->_renderInput = false;
     }
     parent::init();
     JsonEditorAsset::register($this->getView());
 }