getInputName() публичный статический Метод

This method generates a name that can be used as the input name to collect user input for the specified attribute. The name is generated according to the [[Model::formName|form name]] of the model and the given attribute name. For example, if the form name of the Post model is Post, then the input name generated for the content attribute would be Post[content]. See BaseHtml::getAttributeName for explanation of attribute expression.
public static getInputName ( Model $model, string $attribute ) : string
$model yii\base\Model the model object
$attribute string the attribute name or expression
Результат string the generated input name
Пример #1
0
 public function run()
 {
     $options = $this->options;
     if (isset($options['id'])) {
         $id = $options['id'];
     } else {
         $id = 'editor';
     }
     if (isset($options['name'])) {
         $name = $options['name'];
     } elseif ($this->hasModel()) {
         $name = BaseHtml::getInputName($this->model, $this->attribute);
     } else {
         $name = $this->name;
     }
     if (isset($options['value'])) {
         $value = $options['value'];
     } elseif ($this->hasModel()) {
         $value = BaseHtml::getAttributeValue($this->model, $this->attribute);
     } else {
         $value = $this->value;
     }
     echo Html::beginTag('script', ['id' => $id, 'type' => 'text/plain', 'name' => $name, 'style' => "height:{$this->height}"]);
     echo $value;
     echo Html::endTag('script');
     if (!isset($options['config'])) {
         $options['config'] = [];
     }
     $ueditorConfig = ArrayHelper::merge(['serverUrl' => Url::to(['ueditor/controller'])], $options['config']);
     $config = Json::encode($ueditorConfig);
     $view = $this->getView();
     UEditorAsset::register($view);
     $view->registerJs("var ue = UE.getEditor('{$id}', {$config});");
 }
 public function run()
 {
     $this->view->registerAssetBundle(MultiSelectAsset::className());
     $options = $this->options;
     if (isset($options['id'])) {
         $id = $options['id'];
     } else {
         $id = BaseHtml::getInputId($this->model, $this->attribute);
     }
     if (isset($options['name'])) {
         $name = $options['name'];
     } elseif ($this->hasModel()) {
         $name = BaseHtml::getInputName($this->model, $this->attribute);
     } else {
         $name = $this->name;
     }
     //        if (isset($options['value'])) {
     //            $value = $options['value'];
     //        } elseif ($this->hasModel()) {
     //            $value = BaseHtml::getAttributeValue($this->model, $this->attribute);
     //        } else {
     //            $value = $this->value;
     //        }
     $len = strlen($this->attribute);
     $widget = Html::beginTag('div', ['id' => $id, 'name' => $name]);
     foreach ($this->model as $k => $v) {
         if (substr($k, 0, $len + 1) == $this->attribute . '_') {
             $widget .= Html::activeCheckbox($this->model, $k, ['labelOptions' => ['class' => 'checkbox-inline']]);
         }
     }
     $widget .= Html::endTag('div');
     echo $widget;
 }
Пример #3
0
 protected function renderFooterCellContentJS($model)
 {
     $key = '';
     if ($this->value !== null) {
         if (is_string($this->value)) {
             return ArrayHelper::getValue($model, $this->value);
         } else {
             return call_user_func($this->value, $model, '', '', $this);
         }
     } elseif ($this->attribute !== null) {
         $html = '<a id="thumb-image-\'+data.id+\'" class="img-thumbnail" href="/index.php?r=catalog%2Fadmin%2Fupdate&amp;id=17" data-toggle="image">';
         $html .= Html::img(\andreosoft\image\Image::thumb($model[$this->attribute], 100, 100), ['data-placeholder' => \andreosoft\image\Image::thumb('', 100, 100)]);
         $html .= '</a>';
         $html .= '<input type="hidden" id="input-image-\'+data.id+\'" name="' . \yii\helpers\BaseHtml::getInputName($model, $this->attribute) . '">';
         return $html;
     }
     return null;
 }
Пример #4
0
?>
        <div class="spinner"></div>
        <div class="btn btn-danger"><i class="fa fa-minus-square"></i></div>
    </div>

    <?php 
foreach ($values as $key => $value) {
    ?>

        <div class="block">
            <?php 
    echo Html::input('text', BaseHtml::getInputName($widget->model, $widget->attribute) . '[key][]', empty($value['key']) ? $key : $value['key'], ['class' => 'form-control', 'placeholder' => $widget->placeholder['key']]);
    ?>
            <div class="spinner"></div>
            <?php 
    echo Html::input('text', BaseHtml::getInputName($widget->model, $widget->attribute) . '[value][]', empty($value['value']) ? $value : $value['value'], ['class' => 'form-control', 'placeholder' => $widget->placeholder['value']]);
    ?>
            <div class="spinner"></div>
            <div class="btn btn-danger"><i class="fa fa-minus-square"></i></div>
        </div>
    <?php 
}
?>

    <div class="add-block">
        <div class="btn btn-success"><i class="fa fa-plus-square"></i></div>
    </div>

</div>

<?php 
Пример #5
0
 public function run()
 {
     echo Html::a(Html::img(\andreosoft\image\Image::thumb($this->model[$this->attribute], 100, 100), ['data-placeholder' => \andreosoft\image\Image::thumb('', 100, 100)]), "", ['id' => 'thumb-image', 'data-toggle' => 'image', 'class' => 'img-thumbnail']);
     echo Html::hiddenInput(\yii\helpers\BaseHtml::getInputName($this->model, $this->attribute), $this->model[$this->attribute], ['id' => 'input-image']);
 }
Пример #6
0
 public function renderItem($model, $key, $index)
 {
     $html = Html::a(Html::img(Image::thumb($model['url'], 100, 100), ['data-placeholder' => Image::thumb('', 100, 100)]), "", ['id' => "thumb-image-{$key}", 'data-toggle' => 'image', 'class' => 'img-thumbnail']);
     $html .= Html::hiddenInput(\yii\helpers\BaseHtml::getInputName($model, 'image'), $model['image'], ['id' => "input-image-{$key}"]);
     return $html;
 }
Пример #7
0
 protected function getInput($type, $list = false)
 {
     if ($this->hasModel()) {
         if (isset($this->options['maxlength']) && $this->options['maxlength'] === true) {
             unset($this->options['maxlength']);
             foreach ($this->model->getActiveValidators($this->attribute) as $validator) {
                 if ($validator instanceof StringValidator && $validator->max !== null) {
                     $this->options['maxlength'] = $validator->max;
                     break;
                 }
             }
         }
         if ($this->submit) {
             $this->name = isset($this->options['name']) ? $this->options['name'] : BaseHtml::getInputName($this->model, $this->attribute);
         }
         $this->value = isset($this->options['value']) ? $this->options['value'] : BaseHtml::getAttributeValue($this->model, $this->attribute);
         if (!array_key_exists('id', $this->options)) {
             $this->options['id'] = BaseHtml::getInputId($this->model, $this->attribute);
         }
     }
     return Html::textInput($this->name, $this->value, $this->options);
 }
 private function renderTextBox(){
     return Html::activeTextInput($this->model , $this->attribute,['name' => BaseHtml::getInputName($this->model , $this->attribute).'[]', 'class' => $this->options['class']]);
 }
Пример #9
0
 public function getDataCellValue($model, $key, $index)
 {
     $html = Html::a(Html::img(\andreosoft\image\Image::thumb($model[$this->attribute], 100, 100), ['data-placeholder' => \andreosoft\image\Image::thumb('', 100, 100)]), "", ['id' => "thumb-image-{$key}", 'data-toggle' => 'image', 'class' => 'img-thumbnail']);
     $html .= Html::hiddenInput(\yii\helpers\BaseHtml::getInputName($model, $this->attribute), $model[$this->attribute], ['id' => "input-image-{$key}"]);
     return $html;
 }