duanbiaojin8860
2017-06-19 12:41 阅读 83
已采纳

SQLSTATE [HY000]:常规错误:1364字段'reply_text'没有默认值

I have a page that shows a topic, And underneath the topic there are replies. In between these 2, there is a text field where the user can type a reply. The problem is. I get the error in the title when I try to post a reply. I used the same method on a previous project of mine and there it works just fine. How can I solve this?

Here are the files

topic.blade.php

<div class="card">
            <div class="card-content">
                <span class="card-title">Leave a Reply</span>
                <div class="row">
                    <form method="POST" action="{{ route('createreply') }}">
                        {{ csrf_field() }}
                        <input type="hidden" name="user_id" value="{{ Auth::user()->id }}">
                        <input type="hidden" name="post_id" value="{{ $topic->id }}">
                        <div class="form-group col s12">
                            <textarea id="message-body textarea1" class="form-control materialize-textarea" name="reply" placeholder="Type your reply"></textarea>
                        </div>
                        <div class="col s12">
                            <button class="btn right blue-grey darken-4" type="submit">Reply</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>

ReplyController.php (Store method)

 public function store(Request $request)
 {
    Reply::create($request->input());

    return back();
 }

Web.php

route::post('/reply/create', 'ReplyController@store')->name('createreply');

Thank you in advance!

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

1条回答 默认 最新

  • 已采纳
    dongyao4419 dongyao4419 2017-06-19 12:48
    <textarea id="message-body textarea1" class="form-control materialize-textarea" name="reply_text" placeholder="Type your reply"></textarea>
    

    Try this. The name attribute was not reply_text as you have in db

    点赞 评论 复制链接分享

相关推荐