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
The PHP warning: Illegal string offset happens when you try to access a string type data as if it's an array . When you try to access $myString above using an index that's not available, the PHP warning: Illegal string offset occurs.
The "Illegal string offset" warning when using $inputs['type'] means that the function is being passed a string instead of an array. (And then since a string offset is a number, 'type' is not suitable.)
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With