Laravel输入:get()不起作用 [英] Laravel Input:get() not working

查看:119
本文介绍了Laravel输入:get()不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Laravel 4中使用post函数.我的表单具有许多字段,在提交时,这些字段将转到控制器中的post函数.

I'm trying to work on a post function in Laravel 4. My form has a number of fields that on submitting, goes to the post function in the controller.

问题在于,表单中的字段的名称之间存在空格.

The problem is, the fields in the form have names which have spaces between them.

例如,类型1" 是输入的名称,并且之间有一个空格.现在,当我尝试通过执行Input::get('Type 1')来获取该字段的值时,它没有返回任何值.但是,如果我将表单中的名称更改为"Type1",它将返回输入的值.

For example, "Type 1" is a name of an input and it has a space in between. Now, when I'm trying to get that field's value by doing Input::get('Type 1'), it's not returning any value. But if I change the name in the form to "Type1", it returns the value entered.

是否有解决此问题的方法?我无法删除空格,因为这些是来自数据库的动态名称.它们可以是长名,一个单词或任何东西.所以我不能保持静态解决方案.

Is there a solution to this problem? I can't remove the space because these are dynamic names coming from the database. They can be long names, one word or anything. So I can't keep a static solution.

我可能会使用id并将其用于操纵数据,但这会降低便利性.那将是我的最后选择.有解决方案吗?

I could probably take the id and use that to manipulate the data, but that would decrease the convenience. That would be my last resort. Any solutions?

谢谢.

推荐答案

名称中的空格已转换为破折号.对于您的情况,请尝试:

Spaces in name were converted to dash. In your case, try:

Input :: get('Type_1');

Input::get('Type_1');

这篇关于Laravel输入:get()不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆