使用模式编辑数据时无法保存数据

时间:2018-10-24 03:53:01

标签: php laravel-5 modal-dialog edit laravel-5.7

我无法保存编辑的数据?

index.blade.php

<td>
    <a href="" class="edit_real" data-toggle="modal" data-target="#edit_real-{{$spent_time->plan_id}}">
        {{$spent_time->plan->user_story}} 
    </a>
    @include('reals._form')
</td>

刀片中的形式模态

<div class="modal fade" id="edit_real-{{$spent_time->plan_id}}" role="dialog" >
    <div class="modal-dialog modal-sm-8">
        <div class="modal-content">
            <div class="nav-tabs-custom">
                <ul class="nav nav-tabs pull-left">
                    <li class=""><a href="{{url('plan')}}">Plan</a></li>
                    <li class="active"><a href="{{url('real')}}">Real</a></li>
                </ul>

                <div class="tab-content">
                    <div class="chart tab-pane active" id="revenue-chart">
                        {!! Form::open([$spent_time, 'url' => route('real.update', $spent_time->id), 'method' => 'POST', 'role'=>'form']) !!}
                        {{ csrf_field() }} {{ method_field('PUT') }}

                        <div class="box-body">
                            <div class="form-group">
                                {!! Form::label('user_story','Today Plan *', ['class' => 'control-label', 'name'=>'user_story']) !!}</label>
                                {!! Form::text('user_story', old('plan_id', is_null($spent_time->plan->user_story) ? null : $spent_time->plan->user_story), ['class'=>'form-control', 'readonly' => 'true']) !!}                   
                            </div>

                            <div class="form-group">
                                {!! Form::label('daily_spent_time','Spent Time *', ['class' => 'control-label', 'name'=>'daily_spent_time']) !!}</label>
                                {!! Form::text('daily_spent_time', old('daily_spent_time', $spent_time->daily_spent_time ?: null), ['class'=>'form-control', 'id'=>'daily_spent_time']) !!}                   
                            </div>

                            <div class="form-group">
                                {!! Form::label('daily_percentage','% Done *', ['class' => 'control-label', 'name' => 'daily_percentage']) !!}</label>
                                {!! Form::text('daily_percentage', old('daily_percentage', $spent_time->daily_percentage ?: null), ['class'=>'form-control']) !!}
                            </div>

                            <div class="form-group">
                                {!! Form::label('reason','Reason', ['class' => 'control-label', 'name'=>'reason']) !!}</label>
                                {!! Form::textarea('reason', old('reason', $spent_time->reason ?: null), ['class'=>'form-control']) !!}  
                            </div>

                            <div class="form-group">
                                {!! Form::submit('Save', ['class' => 'btn btn-block btn-primary btn-flat']) !!}
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

这是形式模式的脚本

<script>
    // jquery
    $('.edit_real').on('click', function (event) {
        event.preventDefault();

        $('#edit_real').modal();
    });
</script>

编辑时会读取数据,但无法保存到红线中的表

enter image description here

无法保存到红线中的表

enter image description here

要点

<td>
    <a href="" class="edit_real" data-toggle="modal" data-target="#edit_real-{{$spent_time->plan_id}}">
        {{$spent_time->plan->user_story}}  
    </a>
    @include('reals._form')
</td>

我在哪里弄错了?

1 个答案:

答案 0 :(得分:0)

  

在_form.blade.php中,输入'type' => 'submit'   像这样

_form.blade.php(模态)

<div class="form-group">
   {!! Form::submit('Save', ['class' => 'btn btn-block btn-primary btn-flat', 'type'=>'submit']) !!}
</div>