Php 提交表单是否将标题显示为正文内容?

Php 提交表单是否将标题显示为正文内容?,php,laravel,laravel-5.3,Php,Laravel,Laravel 5.3,当在我的网站上提交表单时,它应该显示标题和正文内容,但是它似乎忽略了标题,并用正文内容替换了两者? 下面是导致问题的代码。 DB有两个字段name和body,并且在控制器中是正确的 这是创建内容的表单- <form action="{{ route('document', $project->slug) }}" method="POST"> <div class="add-form center-block">

当在我的网站上提交表单时,它应该显示标题和正文内容,但是它似乎忽略了标题,并用正文内容替换了两者? 下面是导致问题的代码。 DB有两个字段name和body,并且在控制器中是正确的

这是创建内容的表单-

<form  action="{{ route('document', $project->slug) }}" method="POST">
                <div class="add-form center-block">
                    <div class="input-group">
                        <input type="text" class="form-control" style="height:35px;" required="required" name="name" placeholder="Add document title">{{ old('document') }}
                    </div>
                </div>
                {{ csrf_field() }}
            </form>
        </div>
        <form  action="{{ route('document', $project->slug) }}" method="POST">    
            <div class="input-group">
                <textarea id="summernote" name="document" required="required" placeholder="Craft your document here..."></textarea>
                <script>
                    $('#summernote').summernote({
                        height: 200, // set editor height
                        minHeight: null, // set minimum height of editor
                        maxHeight: 300, // set maximum height of editor
                        focus: true                  // set focus to editable area after initializing summernote
                    });
                </script>
            </div>
            <button type="submit" class="btn btn-dash">
                <i class="fa fa-btn fa-plus"></i> create
            </button>
            {{ csrf_field() }}
        </form>
@foreach ($documents as $document)
    <div class="modal-content">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
            <h4 class="modal-title" id="myModalLabel"> {!! nl2br($document->name) !!}</h4>
        </div>
        <div class="modal-body">
            {!! nl2br($document->body) !!}
        </div>
        <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        </div>
    </div>
    @endforeach
</div>

{{old('document')}
{{csrf_field()}}
$('#summernote')。summernote({
高度:200,//设置编辑器高度
minHeight:null,//设置编辑器的最小高度
maxHeight:300,//设置编辑器的最大高度
focus:true//初始化summernote后将焦点设置为可编辑区域
});
创造
{{csrf_field()}}
下面是显示提交内容的代码-

<form  action="{{ route('document', $project->slug) }}" method="POST">
                <div class="add-form center-block">
                    <div class="input-group">
                        <input type="text" class="form-control" style="height:35px;" required="required" name="name" placeholder="Add document title">{{ old('document') }}
                    </div>
                </div>
                {{ csrf_field() }}
            </form>
        </div>
        <form  action="{{ route('document', $project->slug) }}" method="POST">    
            <div class="input-group">
                <textarea id="summernote" name="document" required="required" placeholder="Craft your document here..."></textarea>
                <script>
                    $('#summernote').summernote({
                        height: 200, // set editor height
                        minHeight: null, // set minimum height of editor
                        maxHeight: 300, // set maximum height of editor
                        focus: true                  // set focus to editable area after initializing summernote
                    });
                </script>
            </div>
            <button type="submit" class="btn btn-dash">
                <i class="fa fa-btn fa-plus"></i> create
            </button>
            {{ csrf_field() }}
        </form>
@foreach ($documents as $document)
    <div class="modal-content">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
            <h4 class="modal-title" id="myModalLabel"> {!! nl2br($document->name) !!}</h4>
        </div>
        <div class="modal-body">
            {!! nl2br($document->body) !!}
        </div>
        <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        </div>
    </div>
    @endforeach
</div>
@foreach($documents作为$document)
&时代;
{!!nl2br($document->name)!!}
{!!nl2br($document->body)
接近
@endforeach
带所有代码的JSfiddle

因为您使用2个不同的表单而不是1个,所以您需要编写2次表单操作。拆下第二个,我把它包在一个里还是只拆下一个就行了?只拆下第二个表单动作行。并提供有关$document的信息。它是来自数据库还是从Post请求返回?在这种情况下,您也不需要使用foreach。好的,我会试试这个谢谢您的快速回复:)其次,您的textarea名称是document,但在foreach中您使用$document->body。