Laravel: returning null from input::get()


Laravel: returning null from input::get()

我需要一个动态表单,它是根据数据库条目创建的。为了将数据输入到数据库中,这也需要是动态的。由于某种原因,我的表格值为空。

我的表单循环

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

返回

<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 />

当我的表单提交时,它调用动作控制器并运行以下代码

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();
    }

在SQL错误中,我得到的year_to_date变量为null,即使数据已经填写完毕。

这是我的输入::get()的var_dump

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

我没有;我不知道为什么,但第一个条目为空。数据库中总共有三个条目,并且没有名称变量为空

在存在空格字符的位置自动转换为下划线。删除空格字符或转换为下划线。尝试输入::get('hsbc_dad')

下面是的另一个例子