当我在应用名称,电子邮件和手机中输入我的注册表单时,手机不会显示,并且会以奇怪的格式保存。
当我运行php artisan tinker:
DB::table('user1s')->get();
=> [
{#640
+"id": 1,
+"name": """
\x09
\x09sda\t
""",
+"email": """
\x09
\x09sds\t
""",
+"phone_number": "",
+"created_at": "2016-07-02 11:28:04",
+"updated_at": "2016-07-02 11:28:04",
},
{#642
+"id": 2,
+"name": """
\x09
\x09da
""",
+"email": """
sd\x09
\x09
""",
+"phone_number": "",
+"created_at": "2016-07-02 11:33:56",
+"updated_at": "2016-07-02 11:33:56",
},
{#643
+"id": 3,
+"name": """
more in-\x0D
\x09
""",
+"email": """
\x09
\x09more in-
""",
+"phone_number": "",
+"created_at": "2016-07-02 11:52:43",
+"updated_at": "2016-07-02 11:52:43",
},
]
视图中的表单如下所示:
@extends('layout')
@section('content')
<div class="row">
<div class="col-md-6 col-md-offset-3">
<h1> Welcome please register! </h1>
<h1>All users</h1>
@foreach ($user1s as $user1)
<div>
{{ $user1->phone_number }}
</div>
@endforeach
<hr>
<h3>Fill in required informations</h3>
<form method="POST" action=" ">
<input name="_token" type="hidden" value="{{ csrf_token() }}"/>
<ul class="list-group" >
Name
<div class="form-group" title="name" >
<textarea name="name" class="form-control" ></textarea>
</div>
Email
<div class="form-group" title="email">
<textarea name="email" class="form-control" ></textarea>
</div>
Phone number
<div class="form-group" title="phone_number">
<textarea name="phone_number" class="form-control" ></textarea>
</div>
<div class="form-group" >
<button class="btn btn-primary">Register</button>
</div>
</ul>
</form>
@foreach($errors->all() as $error)
{{ $error }}
@endforeach
</div>
</div>
@endsection
我的迁移:
public function up()
{
Schema::create('user1s', function (Blueprint $table) {
$table->increments('id');
$table->string("name");
$table->string("email");
$table->string("phone_number");
$table->timestamps();
});
}
有人看到了这个问题吗?
答案 0 :(得分:0)
这里的问题在于您的Controller(或终端路由)代码。如评论中所述,您错过了保存phone_number
项目。