/**
  * @inheritdoc
  * @throws InvalidConfigException
  */
 public function init()
 {
     parent::init();
     Config::checkDependency('editable\\Editable', 'yii2-editable', 'for GridView EditableColumn');
     $this->_css = 'kv-edcol-' . hash('crc32', uniqid(rand(1, 100), true));
     if ($this->refreshGrid) {
         EditableColumnAsset::register($this->_view);
     }
 }
Example #2
0
 /**
  * @inheritdoc
  * @throws InvalidConfigException
  */
 public function init()
 {
     parent::init();
     \kartik\base\Config::checkDependency('editable\\Editable', 'yii2-editable', 'for GridView EditableColumn');
     $this->_css = 'kv-edcol-' . hash('crc32', uniqid(rand(1, 100), true));
     if ($this->refreshGrid) {
         EditableColumnAsset::register($this->_view);
         $id = $this->grid->options['id'];
         $this->_view->registerJs("kvRefreshEC('{$id}','{$this->_css}');");
     }
 }
 /**
  * @inherit doc
  * @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';
     }
     if ($this->type === self::TYPE_SELECT2) {
         Config::checkDependency('select2\\Select2', 'yii2-widget-select2', 'for dependent dropdown for TYPE_SELECT2');
     }
     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(!empty($this->typename) ? $this->typename : 'dropdownList', true);
     }
 }
Example #4
0
 /**
  * Runs the widget
  *
  * @throws InvalidConfigException
  */
 public function run()
 {
     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 identifiers.");
     }
     if (empty($this->options['class'])) {
         $this->options['class'] = 'form-control';
     }
     if ($this->type === self::TYPE_SELECT2) {
         Config::checkDependency('select2\\Select2', 'yii2-widget-select2', 'for dependent dropdown for Select2');
     }
     if ($this->type !== self::TYPE_SELECT2 && !empty($this->options['placeholder'])) {
         $this->data = ['' => $this->options['placeholder']] + $this->data;
     }
     $this->registerAssets();
 }
Example #5
0
 /**
  * @inheritdoc
  * @throws InvalidConfigException
  */
 public function init()
 {
     parent::init();
     \kartik\base\Config::checkDependency('editable\\Editable', 'yii2-editable', 'for GridView EditableColumn');
     $this->_css = 'kv-edcol-' . hash('crc32', uniqid(rand(1, 100), true));
 }
Example #6
0
 /**
  * @inheritdoc
  * @throws InvalidConfigException
  */
 public function run()
 {
     $this->initToggleData();
     $this->initExport();
     if ($this->export !== false && isset($this->exportConfig[self::PDF])) {
         \kartik\base\Config::checkDependency('mpdf\\Pdf', 'yii2-mpdf', "for PDF export functionality. To include PDF export, follow the install steps below. If you do not " . "need PDF export functionality, do not include 'PDF' as a format in the 'export' property. You can " . "otherwise set 'export' to 'false' to disable all export functionality");
     }
     $this->initHeader();
     $this->initBootstrapStyle();
     $this->containerOptions['id'] = $this->options['id'] . '-container';
     Html::addCssClass($this->containerOptions, 'kv-grid-container');
     $this->registerAssets();
     $this->renderPanel();
     $this->initLayout();
     $this->beginPjax();
     parent::run();
     $this->endPjax();
 }
Example #7
0
 public function validateSettings()
 {
     if (!$this->hasModel() && ($this->name1 === null || $this->name2 === null)) {
         throw new InvalidConfigException("Either 'name1','name2' or 'attribute1', 'attribute2' with 'model' properties must be specified.");
     }
     if (!$this->_isInput && $this->type !== self::INPUT_WIDGET && !in_array($this->type, self::$_inputWidgets)) {
         throw new InvalidConfigException("Invalid value for 'type'. Must be one of the FieldRange::INPUT constants.");
     }
     if (isset($this->form) && $this->useAddons && !$this->form instanceof ActiveForm) {
         Config::checkDependency('form\\ActiveForm', ['yii2-widget-activeform', 'yii2-widgets'], "when 'useAddons' is set to true.");
         throw new InvalidConfigException("The 'form' property must be an instance of '\\kartik\\form\\ActiveForm' or '\\kartik\\widgets\\ActiveForm' when 'useAddons' is set to true.");
     }
     if (isset($this->form) && !$this->useAddons && !$this->form instanceof \yii\widgets\ActiveForm) {
         throw new InvalidConfigException("The 'form' property must be an instance of '\\yii\\widgets\\ActiveForm'.");
     }
     if (isset($this->form) && !$this->hasModel()) {
         throw new InvalidConfigException("The 'model' and 'attribute1', 'attribute2' property must be set when 'form' is set.");
     }
     if ($this->type === self::INPUT_WIDGET && empty($this->widgetClass)) {
         throw new InvalidConfigException("The 'widgetClass' property must be set for widget input type.");
     }
 }
 /**
  * @inheritdoc
  * @throws InvalidConfigException
  */
 public function init()
 {
     parent::init();
     \kartik\base\Config::checkDependency('editable\Editable', 'yii2-editable', 'for GridView EditableColumn');
 }
Example #9
0
 /**
  * Initializes options and settings
  * @throws InvalidConfigException
  */
 protected function initOptions()
 {
     if ($this->type == self::TYPE_GROWL) {
         Config::checkDependency('growl\\Growl', 'yii2-widget-growl', 'for rendering Growl notifications in the alert block');
     }
     if (empty($this->options['id'])) {
         $this->options['id'] = $this->getId();
     }
     if (!isset($this->delay)) {
         $this->delay = $this->type == self::TYPE_ALERT ? 2000 : 1200;
     }
     if (empty($this->alertSettings) && $this->type == self::TYPE_GROWL) {
         $this->alertSettings = ['error' => ['type' => Growl::TYPE_DANGER], 'success' => ['type' => Growl::TYPE_SUCCESS], 'info' => ['type' => Growl::TYPE_INFO], 'warning' => ['type' => Growl::TYPE_WARNING], 'growl' => ['type' => Growl::TYPE_GROWL]];
     } elseif (empty($this->alertSettings)) {
         $this->alertSettings = ['error' => ['type' => Alert::TYPE_DANGER], 'success' => ['type' => Alert::TYPE_SUCCESS], 'info' => ['type' => Alert::TYPE_INFO], 'warning' => ['type' => Alert::TYPE_WARNING], 'primary' => ['type' => Alert::TYPE_PRIMARY], 'default' => ['type' => Alert::TYPE_DEFAULT]];
     }
 }