【问题标题】:how to Insert a value from drop down in the database in laravel 5.2如何在 laravel 5.2 的数据库中从下拉列表中插入一个值
【发布时间】:2016-09-05 06:32:26
【问题描述】:

generaljournal.blade.php

 <div class="form-group">
                    {!!Form::label('Account Type','Account Type',array('class'=>'col-sm-2 control-label'))!!}
                    <div class="col-sm-10">
                    {!!Form::select('size', array('GL' => 'G/L Account', 'C' => 'Customer','Vendor' => 'Vendor','Bank' => 'Bank Account','Fixed Asset' => 'Fixed Asset','Member' => 'Member'), 'GL')!!}
                    </div>
                    </div>

GeneralController.php

public function store(Request $request)
    {
        //
         $Generals = new General;
        $Generals->Line_No = $request->Line_No;
        $Generals->Posting_Date = $request->Posting_Date;
        $Generals->Document_No= $request->Document_No;
        $Generals->Account_Type = $request->Account_Type;
        $Generals->save(); 

        return redirect()->action('GeneralController@index');
    }

错误是

Connection.php 第 673 行中的 QueryException:SQLSTATE[23000]:完整性 违反约束:1048 列“Account_Type”不能为空(SQL: 插入general journal (Line_No, Posting_Date, Document_No, Account_Type) 值 (6000, 20/05/2016, Doc0001, , ))

我在 account_type 上遇到错误,它的值应该是从下拉列表中选择的。有人请帮助我是 laravel 的新手

【问题讨论】:

    标签: laravel-5


    【解决方案1】:

    刀片中没有名称为 Account_Type 的元素。 尝试更改此设置

    {!!Form::select('size', array('GL' => 'G/L Account', 'C' => 'Customer','Vendor' => 'Vendor','Bank' => 'Bank Account','Fixed Asset' => 'Fixed Asset','Member' => 'Member'), 'GL')!!}
    

    到这里

    {!!Form::select('Account_Type', array('GL' => 'G/L Account', 'C' => 'Customer','Vendor' => 'Vendor','Bank' => 'Bank Account','Fixed Asset' => 'Fixed Asset','Member' => 'Member'), 'GL')!!}
    

    【讨论】:

    • 乐于助人。请选择它作为接受的答案。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-20
    • 1970-01-01
    • 2017-04-18
    • 1970-01-01
    相关资源
    最近更新 更多