/** * Initializes the widget * * @throw InvalidConfigException */ public function init() { parent::init(); $this->setPluginOptions(); $this->registerAssets(); echo $this->getInput('textInput'); }
/** * Initializes the widget * * @throw InvalidConfigException */ public function init() { parent::init(); $this->registerAssets(); if ($this->pluginLoading) { Html::addCssClass($this->options, 'rating-loading'); } echo $this->getInput('textInput'); }
/** * Initializes the widget * * @throw InvalidConfigException */ public function init() { parent::init(); if (empty($this->dataset) || !is_array($this->dataset)) { throw new InvalidConfigException("You must define the 'dataset' property for Typeahead which must be an array."); } if (!is_array(current($this->dataset))) { throw new InvalidConfigException("The 'dataset' array must contain an array of datums. Invalid data found."); } $this->registerAssets(); $this->renderInput(); }
/** * Initializes the widget * * @throw InvalidConfigException */ public function init() { parent::init(); if (empty($this->type) && $this->type !== self::CHECKBOX && $this->type !== self::RADIO) { throw new InvalidConfigException("You must define a valid 'type' which must be either 1 (for checkbox) or 2 (for radio)."); } if ($this->type == self::RADIO) { if (empty($this->items) || !is_array($this->items)) { throw new InvalidConfigException("You must setup the 'items' array for the 'radio' type."); } } $this->registerAssets(); echo $this->renderInput(); }
/** * Initializes the widget * * @throw InvalidConfigException */ public function init() { parent::init(); if ($this->type < 1 || $this->type > 4 || !is_int($this->type)) { throw new InvalidConfigException("Invalid value for the property 'type'. Must be an integer between 1 and 4."); } $this->initLanguage(); if ($this->convertFormat && isset($this->pluginOptions['format'])) { $this->pluginOptions['format'] = static::convertDateFormat($this->pluginOptions['format']); } $this->_id = $this->type == self::TYPE_INPUT ? 'jQuery("#' . $this->options['id'] . '")' : 'jQuery("#' . $this->options['id'] . '").parent()'; $this->registerAssets(); echo $this->renderInput(); }
/** * Initializes the widget * * @throw InvalidConfigException */ public function init() { parent::init(); $this->_hidden = !empty($this->pluginOptions['data']) || !empty($this->pluginOptions['query']) || !empty($this->pluginOptions['ajax']) || isset($this->pluginOptions['tags']); if (!isset($this->data) && !$this->_hidden) { throw new InvalidConfigException("No 'data' source found for Select2. Either the 'data' property must be set OR one of 'data', 'query', 'ajax', or 'tags' must be set within 'pluginOptions'."); } if (!empty($this->options['placeholder']) && !$this->_hidden && (empty($this->options['multiple']) || $this->options['multiple'] == false)) { $this->data = ["" => ""] + $this->data; } if (!isset($this->options['style'])) { $this->options['style'] = 'width: 100%'; } $this->registerAssets(); $this->renderInput(); }
/** * Initializes the widget * * @throw InvalidConfigException */ public function init() { if (empty($this->pluginOptions['url'])) { throw new InvalidConfigException("The 'pluginOptions[\"url\"]' property has not been set."); } if (empty($this->pluginOptions['depends']) || !is_array($this->pluginOptions['depends'])) { throw new InvalidConfigException("The 'pluginOptions[\"depends\"]' property must be set and must be an array of dependent dropdown element ID."); } if (empty($this->options['class'])) { $this->options['class'] = 'form-control'; } parent::init(); if ($this->type !== self::TYPE_SELECT2 && !empty($this->options['placeholder'])) { $this->data = ['' => $this->options['placeholder']] + $this->data; } if ($this->type === self::TYPE_SELECT2 && (!empty($this->options['placeholder']) || !empty($this->select2Options['options']['placeholder']))) { $this->pluginOptions['placeholder'] = ''; } elseif ($this->type === self::TYPE_SELECT2 && !empty($this->pluginOptions['placeholder']) && $this->pluginOptions['placeholder'] !== false) { $this->options['placeholder'] = $this->pluginOptions['placeholder']; $this->pluginOptions['placeholder'] = ''; } $this->_view = $this->getView(); $this->registerAssets(); if ($this->type === self::TYPE_SELECT2) { if (empty($this->data)) { $this->data = ['' => '']; } if ($this->hasModel()) { $settings = ArrayHelper::merge($this->select2Options, ['model' => $this->model, 'attribute' => $this->attribute, 'data' => $this->data, 'options' => $this->options]); } else { $settings = ArrayHelper::merge($this->select2Options, ['name' => $this->name, 'value' => $this->value, 'data' => $this->data, 'options' => $this->options]); } echo Select2::widget($settings); $id = 'jQuery("#' . $this->options['id'] . '")'; $text = ArrayHelper::getValue($this->pluginOptions, 'loadingText', 'Loading ...'); $this->_view->registerJs("{$id}.on('depdrop.beforeChange',function(e,i,v){{$id}.select2('data',{text: '{$text}'});});"); $this->_view->registerJs("{$id}.on('depdrop.change',function(e,i,v,c){{$id}.select2('val',{$id}.val());});"); } else { echo $this->getInput('dropdownList', true); } }
/** * @var array initialize the FileInput widget */ public function init() { parent::init(); Yii::setAlias('@fileinput', dirname(__FILE__)); if (empty($this->i18n)) { $this->i18n = ['class' => 'yii\\i18n\\PhpMessageSource', 'basePath' => '@fileinput/messages']; } Yii::$app->i18n->translations['fileinput'] = $this->i18n; $this->registerAssets(); if ($this->pluginLoading) { Html::addCssClass($this->options, 'file-loading'); } $input = $this->getInput('fileInput'); $id = 'jQuery("#' . $this->options['id'] . '")'; if ($this->showMessage) { $validation = ArrayHelper::getValue($this->pluginOptions, 'showPreview', true) ? 'file preview and multiple file upload' : 'multiple file upload'; $message = '<strong>' . Yii::t('fileinput', 'Note:') . '</strong> ' . Yii::t('fileinput', 'Your browser does not support {validation}. Try an alternative or more recent browser to access these features.', ['validation' => $validation]); $content = Html::tag('div', $message, $this->messageOptions) . "<script>{$id}.removeClass('file-loading');</script>"; $input .= "\n<br>" . $this->validateIE($content); } echo $input; }
/** * Initializes the widget * * @throw InvalidConfigException */ public function init() { parent::init(); $this->registerAssets(); echo Html::tag('div', $this->renderInput(), $this->containerOptions); }
/** * Initializes the widget * * @throw InvalidConfigException */ public function init() { parent::init(); if ($this->type === self::TYPE_RANGE && $this->attribute2 === null && $this->name2 === null) { throw new InvalidConfigException("Either 'name2' or 'attribute2' properties must be specified for a datepicker 'range' markup."); } if ($this->type === self::TYPE_RANGE && !class_exists('\\kartik\\field\\FieldRangeAsset')) { throw new InvalidConfigException("The yii2-field-range extension is not installed and is a pre-requisite for a DatePicker RANGE type. To install this extension run this command on your console: \n\nphp composer.phar require kartik-v/yii2-field-range \"*\""); } if ($this->type < 1 || $this->type > 5 || !is_int($this->type)) { throw new InvalidConfigException("Invalid value for the property 'type'. Must be an integer between 1 and 5."); } if (isset($this->form) && !$this->form instanceof \yii\widgets\ActiveForm) { throw new InvalidConfigException("The 'form' property must be of type \\yii\\widgets\\ActiveForm"); } if (isset($this->form) && !$this->hasModel()) { throw new InvalidConfigException("You must set the 'model' and 'attribute' properties when the 'form' property is set."); } if (isset($this->form) && $this->type === self::TYPE_RANGE && !isset($this->attribute2)) { throw new InvalidConfigException("The 'attribute2' property must be set for a 'range' type markup and a defined 'form' property."); } $this->initLanguage(); if ($this->convertFormat && isset($this->pluginOptions['format'])) { $this->pluginOptions['format'] = static::convertDateFormat($this->pluginOptions['format']); } $this->_id = $this->type == self::TYPE_INPUT ? 'jQuery("#' . $this->options['id'] . '")' : 'jQuery("#' . $this->options['id'] . '").parent()'; $this->registerAssets(); echo $this->renderInput(); }
/** * Runs the widget */ public function init() { parent::init(); $this->initInput(); }
/** * Initializes widget * * @throws \yii\base\InvalidConfigException */ public function init() { $this->initModule(); if (!isset($this->ajaxConversion)) { $this->ajaxConversion = $this->_module->ajaxConversion; } if (!$this->ajaxConversion && ($this->displayTimezone != null || $this->saveTimezone != null)) { throw new InvalidConfigException("You must set 'ajaxConversion' to 'true' when using time-zones for display or save."); } parent::init(); $this->_displayAttribName = ($this->hasModel() ? $this->attribute : $this->name) . '-' . $this->options['id']; $this->saveOptions['id'] = $this->options['id']; $this->options['id'] = $this->options['id'] . '-disp'; $this->_doTranslate = isset($this->language) && substr($this->language, 0, 2) != 'en'; if ($this->_doTranslate && $this->autoWidget) { $this->_widgetSettings[$this->type]['options']['pluginOptions']['language'] = $this->language; } $this->setLocale(); }