在create.blade.php中创建的表单
{!! Form::open(['route' => 'employees.store', 'class' => 'form', 'enctype' => 'multipart/form-data']) !!}
<div class="form-group">
{!! Form::label('name', 'Name:', ['class' => 'control-label']) !!}
{!! Form::text('name', null, ['class' => 'form-control']) !!}
</div>
<div class="form-group">
{!! Form::label('male', 'Male:', ['class' => 'control-label']) !!}
{!! Form::radio('gender', 'Male', false, ['id' => 'male']) !!}
{!! Form::label('female', 'Female:', ['class' => 'control-label']) !!}
{!! Form::radio('gender', 'Female', false, ['id' => 'female']) !!}
</div>
<div class="form-group">
{!! Form::label('dob', 'DOB:', ['class' => 'control-label']) !!}
{!! Form::date('dob', null, ['class' => 'form-control']) !!}
</div>
<div class="form-group">
{!! Form::label('image', 'Image:', ['class' => 'control-label']) !!}
{!! Form::file('image') !!}
</div>
<div class="form-group">
<strong>Hobbies:</strong><br>
{!! Form::label('playing', 'Cricket', ['class' => 'control-label']) !!}
{!! Form::checkbox('hobbies[]', 'Cricket', false, ['id' => 'playing']) !!}
{!! Form::label('music', 'Music', ['class' => 'control-label']) !!}
{!! Form::checkbox('hobbies[]', 'Music', false, ['id' => 'music']) !!}
{!! Form::label('travelling', 'Travelling', ['class' => 'control-label']) !!}
{!! Form::checkbox('hobbies[]', 'Travelling', false, ['id' => 'travelling']) !!}
</div>
<div class="form-group">
{!! Form::label('email', 'Email:', ['class' => 'control-label']) !!}
{!! Form::text('email', null, ['class' => 'form-control']) !!}
</div>
<div class="form-group">
{!! Form::label('number', 'Number:', ['class' => 'control-label']) !!}
{!! Form::text('number', null, ['class' => 'form-control']) !!}
</div>
<div class="form-group">
{!! Form::label('city', 'City:', ['class' => 'control-label']) !!}
{!! Form::select('city', ['Bikaner' => 'Bikaner', 'Jaipur' => 'Jaipur', 'Delhi' => 'Delhi'], false, ['class' => 'form-control']) !!}
</div>
<div class="form-group">
{!! Form::label('address', 'Address:', ['class' => 'control-label']) !!}
{!! Form::textarea('address', null, ['class' => 'form-control']) !!}
</div>
<div class="form-group">
{!! Form::submit('Create', ['class' => 'btn btn-primary']) !!}
</div>
{!! Form::close() !!}
控制器
public function store(Request $request)
{
$input = $request->all();
echo "<pre>";print_R($input);exit;
}
当我将包含Gender,Image,Hobbies字段的表单提交为空时,这些字段不会出现在控制器的$ input中,但是当我在填写这些字段后提交表单时,它会显示在$ input中。 /> 那么为什么当这些字段为空时它们不出现呢?