Reputation: 485
This is my view and controller of signup page. I am using laravel framework. I have checked this and it is giving error because of password field. I compiled it without password field and it worked. I am unable to understand what is the problem in it. I copied it fron laravel collective form page.
View:
{!! Form::open(['url' => 'signup/submit']) !!}
<div class="form-group">
{{Form::label('name', 'Name')}}
{{Form::text('name', '', ['class' => 'form-control', 'placeholder' => 'Full Name'])}}
</div>
<div class="form-group">
{{Form::label('username', 'Username')}}
{{Form::text('username', '', ['class' => 'form-control', 'placeholder' => 'Username'])}}
</div>
<div class="form-group">
{{Form::label('email', 'E-Mail Address')}}
{{Form::email('email', '', ['class' => 'form-control', 'placeholder' => 'Your email..'])}}
</div>
<div class="form-group">
{{Form::label('password', 'Password')}}
{{Form::password('password', '123', ['class' => 'form-control', 'placeholder' => 'Password...'])}}
</div>
<div>
{{Form::submit('Submit', ['class' => 'btn btn-primary'])}}
</div>
{!! Form::close() !!}
Controller:
public function submit(Request $request)
{
$this->validate($request, [
'name' => 'required',
'username' => 'username',
'email' => 'email',
'password' => 'password'
]);
//Getting the info and creating new message.
$message = new Message;
$message->name = $request->input('name');
$message->username = $request->input('username');
$message->message = $request->input('email');
$message->message = $request->input('password');
$message->save();
//redirecting
return redirect('/')->with('success', 'Registeration successful');
}
If anyone can understand the problem?
This is the error screen shot: Error screenshot
Upvotes: 5
Views: 7861
Reputation: 329
Ok i found it, it's because the password field doesn't take a display value.
Change this
{{Form::password('password', '123', ['class' => 'form-control', 'placeholder' => 'Password...'])}}
to this
{{Form::password('password', ['class' => 'form-control', 'placeholder' => 'Password...'])}}
From https://laravel.io/forum/08-12-2014-illegal-string-offset-name-when-validating-against-unique
Upvotes: 6
Reputation: 329
You save two times on ->message here
$message->message = $request->input('email');
$message->message = $request->input('password');
So you need to change the field where the password input is saved like:
$message->message = $request->input('email');
$message->password= $request->input('password');
Upvotes: 0