douzhaishan5462 2014-09-15 13:02
浏览 176
已采纳

Laravel:从input :: get()返回null

I need a dynamic form, which is created depending on database entries. To input the data into the database, this also needs to be dynamic. For some reason I am getting null in the value of my form.

My form loop

@foreach ($keyAccounts as $keyAccount)
        {{ Form::label($keyAccount->name, $keyAccount->name.':', array('class' => '')) }}
        {{ Form::text($keyAccount->name)}}<br />
    @endforeach

which returns

<label for="hsbc dad" class="">hsbc dad:</label>
        <input name="hsbc dad" type="text" id="hsbc dad"><br />
                <label for="sdsad" class="">sdsad:</label>
        <input name="sdsad" type="text" id="sdsad"><br />
                <label for="dfffff" class="">dfffff:</label>
        <input name="dfffff" type="text" id="dfffff"><br />

When my form is submitted it calls on the actions controller and runs the following code

foreach($keyAccounts as $keyAccount){
        $assignedAccount = new AssignedAccount;
        $assignedAccount->contribution_id = $last_con_id->contribution_id;
        $assignedAccount->key_account_id = $keyAccount->key_account_id; 
        $assignedAccount->year_to_date = Input::get($keyAccount->name);
        $assignedAccount->save();
    }

I am getting the year_to_date variable is null in an SQL error, even though the data is filled out.

here is my var_dump of the Input::get()

NULL string(1) "3" string(1) "3"

I don;t know why but the first entry is null. There is a total of three entries in the database, and no name variable is null

  • 写回答

1条回答 默认 最新

  • douji7399 2014-09-15 13:12
    关注

    Automated conversion to underscores where the space character is present. Remove the space character or convert to underscore. Try Input::get('hsbc_dad')

    Heres another example

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 fluent的在模拟压强时使用希望得到一些建议
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
  • ¥15 怎么配置广告联盟瀑布流
  • ¥15 Rstudio 保存代码闪退
  • ¥20 win系统的PYQT程序生成的数据如何放入云服务器阿里云window版?