我有一个表单,我把它的输入分成两部分,分别是这两个标签:
<ul class="nav nav-pills nav-justified">
<li class="tab active"><a data-toggle="tab" href="#infos">General Infos</a></li>
<li class="tab"><a data-toggle="tab" href="#other">Others</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="infos">
{!! BootForm::open()->action( route('admin.user.create') )->put()->class('validModal')->id('createUserForm') !!}
{!! BootForm::text('Last Name', 'lastname')->placeholder('bkf') !!}
{!! BootForm::text('First Name', 'firstname')->placeholder('aek') !!}
{!! BootForm::text('Username', 'username')->placeholder('bkf.aek') !!}
{!! BootForm::email('Email', 'email')->placeholder('bkf@aek.com') !!}
...
</div>
<div class="tab-pane" id="other">
{!! BootForm::select('Grade', 'grade_id')->options($grades)->select('') !!}
{!! BootForm::password('Password', 'password') !!}
{!! BootForm::password('Password confirmation', 'password_confirmation') !!}
...
</div>
</div>
当我提交带有错过值的表单时,我只在第一个选项卡中出现错误,那么当我点击选项卡时如何在第二个选项卡中显示它们? 我正在寻找这样的事情:
$("li.tab").click(function (){
errors = response.errors;
// Iterate through errors object.
$.each(errors, function(field, message) {
console.error(field+': '+message);
var formGroup = $('[name='+field+']', form).closest('.form-group');
formGroup.addClass('has-error').append('<p class="help-block">'+message+'</p>');
});
});
请问好吗?
答案 0 :(得分:0)
大声笑我通过编辑代码得到了解决方案:
{!! BootForm::open()->action( route('admin.user.create') )->put()->class('validModal')->id('createUserForm') !!}
<ul class="nav nav-pills nav-justified">
<li class="tab active"><a data-toggle="tab" href="#infos">General Infos</a></li>
<li class="tab"><a data-toggle="tab" href="#other">Others</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="infos">
{!! BootForm::text('Last Name', 'lastname')->placeholder('bkf') !!}
...