Skip to content

Commit

Permalink
Add NsValidator to bulk change NS form
Browse files Browse the repository at this point in the history
  • Loading branch information
tafid committed Dec 9, 2015
1 parent 22feb8f commit cda5d94
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/models/Domain.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@
use Exception;
use hipanel\helpers\ArrayHelper;
use hipanel\helpers\StringHelper;
use hipanel\modules\client\validators\NsValidator;
use hipanel\modules\dns\models\Record;
use hipanel\modules\dns\validators\DomainPartValidator;
use hipanel\validators\DomainValidator;
use Yii;
use yii\helpers\Html;
use yii\validators\IpValidator;

class Domain extends \hipanel\base\Model
{
Expand Down Expand Up @@ -99,7 +101,8 @@ public function rules()
[['nameservers', 'nsips'], 'filter', 'filter' => function ($value) {
return !is_array($value) ? StringHelper::mexplode($value) : $value;
}, 'on' => 'OLD-set-ns'],
[['nameservers', 'nsips'], 'each', 'rule' => [DomainValidator::className()], 'on' => 'OLD-set-ns'],
[['nameservers'], 'each', 'rule' => [DomainValidator::className()], 'on' => 'OLD-set-ns'],
[['nsips'], 'each', 'rule' => [NsValidator::class], 'on' => 'OLD-set-ns'],
[['dumb'], 'safe', 'on' => ['get-zones']],
];
}
Expand Down
4 changes: 3 additions & 1 deletion src/widgets/views/ns.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@
<?= $form->field($nsModel, "[$i]name")->textInput(['placeholder' => $nsModel->getAttributeLabel('name')])->label(false) ?>
</div>
<div class="col-md-5">
<?= $form->field($nsModel, "[$i]ip")->textInput(['disabled' => !StringHelper::endsWith($nsModel->name, $model->domain), 'placeholder' => $nsModel->getAttributeLabel('ip')])->label(false) ?>
<?php if (!is_array($model)) : ?>
<?= $form->field($nsModel, "[$i]ip")->textInput(['disabled' => !StringHelper::endsWith($nsModel->name, $model->domain), 'placeholder' => $nsModel->getAttributeLabel('ip')])->label(false) ?>
<?php endif; ?>
</div>
<div class="col-md-2 text-right">
<div class="btn-group" role="group">
Expand Down

0 comments on commit cda5d94

Please sign in to comment.