public function getDataCellValue($model, $key, $index) { $itemName = 'bss_' . $this->attribute . '_' . $key; $modelPkName = reset($model::primaryKey()); if ($this->url) { Yii::$app->view->registerJs(<<<JS var input = \$('input[name="{$itemName}"]'); input.on('switchChange.bootstrapSwitch', function(event, state) { var elem = \$(this); var data = {}; data['{$model->formName()}'] = {}; data['{$model->formName()}']['{$modelPkName}'] = '{$key}'; data['{$model->formName()}']['{$this->attribute}'] = state ? 1 : 0; jQuery.ajax({ 'type': 'POST', 'url': '{$this->url}', 'data': data }).done(function(resp) { var options = { text: resp.text, buttons: { sticker: false }, styling: 'bootstrap3' }; if (resp.success === false) { options.type = 'error'; options.icon = 'fa fa-fw fa-exclamation-triangle'; elem.bootstrapSwitch('toggleReadonly'); } else { options.type = 'success'; options.icon = 'fa fa-fw fa-check-circle'; } if (typeof PNotify != "undefined") { new PNotify(options); } else { alert(resp.text); } }); }); JS ); } return BootstrapSwitch::widget(['name' => $itemName, 'options' => $this->options, 'pluginOptions' => ArrayHelper::merge(['state' => (bool) parent::getDataCellValue($model, $key, $index)], $this->pluginOptions)]); }
echo Html::tag('span', Yii::t('hipanel:domain', 'Use the same name servers for all domains'), ['class' => 'label label-info']); ?> </div> </div> <?php /** @var array $models */ foreach ($models as $id => $model) { ?> <div class="form-group"> <label for="inputEmail3" class="col-sm-4 control-label"><?php echo $model['domain']; ?> </label> <div class="col-sm-6"> <?php echo $form->field($model, "[{$id}]nameservers")->textInput(['value' => $model['nameservers'], 'class' => 'form-control input', 'data-family' => $id, 'placeholder' => 'Type NS servers here...'])->label(false); ?> </div> <div class="col-sm-2"> <?php echo \hiqdev\bootstrap_switch\BootstrapSwitch::widget(['type' => \hiqdev\bootstrap_switch\BootstrapSwitchAsset::TYPE_RADIO, 'name' => 'check', 'items' => [$id => null], 'options' => ['data-family' => $id, 'class' => 'radio'], 'pluginOptions' => ['size' => 'normal', 'radioAllOff' => true, 'onText' => Yii::t('hipanel', 'For all')]]); ?> </div> </div> <?php } $form->end(); ?> <div class="clearfix"></div>