【问题标题】:Set old value of select2 of two same inputs设置两个相同输入的 select2 的旧值
【发布时间】:2021-11-05 21:50:41
【问题描述】:

我需要在 laravel Blade 中设置两个相同输入的旧值。 第一个 div 工作正常,但第二个不工作。

注意:更新方法的请求是

'parent_id' => $request->council_parent_id,

 'parent_id' => $request->parent_id,

this one render the old value but this one is empty

<div class="form-group parent_id">
{{ Form::label('parent_id', 'اختر اللجنة الرئيسية', ['class' => 'control-label']) }}
{{ Form::select('parent_id', $parents, \Input::old('parent_id') , ['placeholder' => '','class' => 'form-control parent_id select2d']) }}
<span class="text-danger">{{ $errors->first('parent_id') }}</span>
<div class="form-group council_parent_id">
{{ Form::label('council_parent_id', 'اختر المجلس الرئيسي', ['class' => 'control-label']) }}
{{ Form::select('council_parent_id', $council_parents,\Input::old('parent_id') , ['placeholder' => '','class' => 'form-control council_parent_id select2', 'value' => $mainCouncil]) }}
<span class="text-danger">{{ $errors->first('parent_id') }}</span>

【问题讨论】:

  • 在你的第二个中你有value =&gt; ... 并尝试通过\Input::old 设置值
  • 你的意思是删除值?
  • 是的,尝试这样做,并在第三个参数中尝试\Input::old('parent_id', $mainCouncil)
  • 感谢您的回复,但仍然无法正常工作,兄弟
  • 还是没有出现

标签: php html laravel laravel-blade


【解决方案1】:

感谢分享。已完成 -apokryfos:

\Input::old('parent_id', $mainCouncil)

<div class="form-group council_parent_id">
{{ Form::label('council_parent_id', 'اختر المجلس الرئيسي', ['class' => 'control-label']) }}
{{ Form::select('council_parent_id', $council_parents,\Input::old('council_parent_id', !empty($mainCouncil->id) ? $mainCouncil->id:''), ['placeholder' => '','class' => 'form-control council_parent_id select2']) }}
<span class="text-danger">{{ $errors->first('council_parent_id') }}</span>

【讨论】:

    猜你喜欢
    • 2016-06-17
    • 2016-04-26
    • 1970-01-01
    • 1970-01-01
    • 2014-01-29
    • 2021-01-08
    • 2016-11-24
    • 2015-04-10
    • 2016-08-12
    相关资源
    最近更新 更多