Closed 99lucky closed 3 years ago
请贴上代码,正常新增和编辑是不会报错的
模板文件 input.blade.php `
<div for="{{ $id }}" class="{{$viewClass['label']}} control-label">
<span>{!! $label !!}</span>
</div>
<div class="{{$viewClass['field']}}">
@include('admin::form.error')
<div class="input-group">
@if ($prepend)
<span class="input-group-prepend"><span class="input-group-text bg-white">{!! $prepend !!}</span></span>
@endif
<input {!! $attributes !!} />
@if ($append)
<span class="input-group-append">{!! $append !!}</span>
@endif
</div>
@include('admin::form.help-block')
</div>
程序文件2.0.9 src/form/field/text.php ` public function render() { $this->initPlainInput();
$this->defaultAttribute('type', 'text')
->defaultAttribute('name', $this->getElementName())
->defaultAttribute('value', $this->value())
->defaultAttribute('class', 'form-control '.$this->getElementClassString())
->defaultAttribute('placeholder', $this->placeholder());
$this->addVariables([
'prepend' => $this->prepend,
'append' => $this->append,
]);
return parent::render();
}`
程序文件1.7.6 ` public function render() { $this->initPlainInput();
$this->defaultAttribute('type', 'text')
**->defaultAttribute('id', $this->id)**
->defaultAttribute('name', $this->getElementName())
->defaultAttribute('value', old($this->column, $this->value()))
->defaultAttribute('class', 'form-control '.$this->getElementClassString())
->defaultAttribute('placeholder', $this->placeholder());
$this->addVariables([
'prepend' => $this->prepend,
'append' => $this->append,
]);
return parent::render();
}
` 我对应了1.7的版本发现2.0.9版本里没有了id的变量赋值
我是让你贴业务代码,id已经废弃了,正常是不会报错的
我明白了,你自己自定义了模板吧,更新一下
哦,看到了,我用的模板文件版本不一致,谢谢
Description:
编辑和创建内容的时候,提示 Undefined variable: id (View: E:\phpstudy_v8\WWW\Voyager\resources\views\dcat\views\form\input.blade.php),对照1.7.1版本发现2.0.9 版本没有了text.php文件里render方法里没有了$id属性设置,按照1.7.1版本加上后,提示没有$id属性
Steps To Reproduce: