示例#1
0
 public function rules()
 {
     return [[['name', 'domain_name'], 'filter', 'filter' => 'trim'], [['name'], FqdnValueValidator::className()], [['ip'], 'filter', 'filter' => function ($value) {
         return StringHelper::explode($value, ',', true, true);
     }, 'skipOnArray' => true], [['ip'], 'each', 'rule' => ['ip']], [['ip'], function ($attribute, $params) {
         if (!StringHelper::endsWith($this->name, $this->domain_name)) {
             $this->addError($attribute, Yii::t('hipanel:domain', 'To assign the IP, NS must be a child from main domain'));
         }
     }]];
 }
示例#2
0
                         <?php 
 echo Html::activeHiddenInput($nsModel, "[{$i}]domain_name", ['value' => $model->domain, 'class' => 'domain_name']);
 ?>
                         <div class="item">
                             <div class="row" style="margin-bottom: 5pt">
                                 <div class="col-md-5">
                                     <?php 
 echo $form->field($nsModel, "[{$i}]name")->textInput(['placeholder' => $nsModel->getAttributeLabel('name'), 'data-attribute' => 'name'])->label(false);
 ?>
                                 </div>
                                 <div class="col-md-5">
                                     <?php 
 if (!is_array($model)) {
     ?>
                                         <?php 
     echo $form->field($nsModel, "[{$i}]ip")->widget(StaticCombo::class, ['formElementSelector' => '.item', 'inputOptions' => ['disabled' => !StringHelper::endsWith($nsModel->name, $model->domain), 'placeholder' => $nsModel->getAttributeLabel('ip'), 'data-attribute' => 'ip', 'value' => implode(',', (array) $nsModel->ip)], 'pluginOptions' => ['select2Options' => ['tags' => [], 'multiple' => true, 'tokenSeparator' => [';', ',', ' '], 'minimumResultsForSearch' => -1, 'createSearchChoice' => new JsExpression('
                                                         function(term, data) {
                                                             return {id:term, text:term};
                                                         }
                                                     '), 'formatNoMatches' => new JsExpression('
                                                         function (term) {
                                                             return "' . Yii::t('hipanel:domain', 'Up to 13 IPv4 or IPv6 addresses separated with comma') . '";
                                                         }
                                                     ')]]])->label(false);
     ?>
                                     <?php 
 }
 ?>
                                 </div>
                                 <div class="col-md-2 text-right">
                                     <div class="btn-group" role="group">