Add User
{{ Form::open(array('action' => 'AdmincpController@adduser')) }}
{{ Form::hidden('do', 'users') }}
<div class="form-group {{set_error('first_name', $errors)}}">
{{ Form::label('first_name', 'First Name', ['class' => 'control-label col-sm-3']) }}
<div class="col-sm-7">
{{ Form::text('first_name', Input::old('first_name'), ['class' => 'form-control']) }}
{{ get_error('first_name', $errors) }}
</div>
</div>
<div class="form-group {{set_error('last_name', $errors)}}">
{{ Form::label('last_name', 'Last Name', ['class' => 'control-label col-sm-3']) }}
<div class="col-sm-7">
{{ Form::text('last_name', Input::old('last_name'), ['class' => 'form-control']) }}
{{ get_error('last_name', $errors) }}
</div>
</div>
<div class="form-group {{set_error('password', $errors)}}">
{{ Form::label('password', 'Password', ['class' => 'control-label col-sm-3']) }}
<div class="col-sm-7">
{{ Form::password('password', Input::old('password'), ['class' => 'form-control']) }}
{{ get_error('password', $errors) }}
</div>
</div>
<div class="form-group {{set_error('email', $errors)}}">
{{ Form::label('email', 'Email', ['class' => 'control-label col-sm-3']) }}
<div class="col-sm-7">
{{ Form::text('email', Input::old('email'), ['class' => 'form-control']) }}
{{ get_error('email', $errors) }}
</div>
</div>
<div class="form-group {{set_error('usergroup', $errors)}}">
{{ Form::label('usergroup', 'User Group', ['class' => 'control-label col-sm-3']) }}
<div class="col-sm-7">
{{ Form::select('usergroup', $data['grouplist'], Input::old('usergroup'), ['class' => 'form-control']) }}
{{ get_error('usergroup', $errors) }}
</div>
</div>
<div class="form-group ">
<div class="col-sm-10">
{{ Form::submit('Save User') }}
</div>
</div>
{{ Form::close() }}
Probably not the issue, but is this a type? Admincpcontroller ?
Have you tried writing your validation rules as follows?
$validator = Validator::make(
array(
'name' => 'Dayle',
'password' => 'lamepassword',
'email' => '[email protected]'
),
array(
'name' => 'required',
'password' => 'required|min:8',
'email' => 'required|email|unique:users'
)
);
The controller type is valid. I have tried making the validation rules as you described, no success.
Hi jafo232,
Try running each validation rule separately to isolate the error.
In your models did you change the table name or in the migration did you change the columns name?
I have not changed the table or column names. The error does not happen until I include the unique validation rule. (Edit: I did try one at a time) The laravel log says:
"Next exception 'ErrorException' with message 'Illegal string offset 'name' (View: /home/mysite/source/app/views/admincp/users.blade.php)' in /home/mysite/source/vendor/laravel/framework/src/Illuminate/Html/FormBuilder.php:226"
That code is:
public function input($type, $name, $value = null, $options = array())
{
if ( ! isset($options['name'])) $options['name'] = $name;
try this
'email' => 'required|email|unique:users,email'
If I modify the input function in FormBuilder.php by adding this line, it fixes it:
if (!is_array($options)) $options = json_decode($options);
I am assuming that sending a json_encoded array in the view is problematic then?
Example:
{{ Form::email('email', Input::old('email'), ['class' => 'form-control']) }}
nadimtuhin said:
try this ...'email' => 'required|email|unique:users,email'
I did try that already with no luck
Jafo232 said:
I am assuming that sending a json_encoded array in the view is problematic then?
Actually I tried changing those to arrays and still had the issue.
Found it. The issue was this:
{{ Form::password('password', Input::old('password'), ['class' => 'form-control']) }}
Password doesn't take a display value. Once I changed it to this:
{{ Form::password('password', ['class' => 'form-control']) }}
Problem solved.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community