我有一个表格中有两个相互连接的字段。模型为City
和State
,其中一个State
可以包含更多Cities
。我想设置我的表单,以便根据我选择的Cities
对State
进行过滤。这不起作用,因为它没有动态添加它。它的最佳方法是什么?
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-6">
<div class="form-group {{ $errors->has('state_id') ? 'has-error' : '' }}">
<label for="state_id">Select State</label>
{!! Form::select('state_id', $states, 'Select State',['class' => 'form-control','placeholder' => 'Select State']) !!}
</div>
</div>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-6">
<div class="form-group {{ $errors->has('city_id') ? 'has-error' : '' }}">
<label for="city_id">Select City</label>
{!! Form::select('city_id', $cities, 'Select City',['class' => 'form-control','placeholder' => 'Select City']) !!}
</div>
</div>