您好我正在使用Laravel(此框架的新功能)和Zizaco / Confide包。我已经设法根据自己的需要编辑了很多偏好,但我似乎无法解决这个关于添加新输入字段以创建新用户作为管理员的问题
请参阅form.day_of_birth字段
该错误表示该字段未填充(我已在屏幕上提交后打印了会话数组)
在AdminUserController中,我更改了PostEdit()方法和PostCreate()方法,添加了以下内容
public function postCreate()
{
$this->user->username = Input::get( 'username' );
$this->user->email = Input::get( 'email' );
$this->user->birthday = Input::get( 'd__day_of_birth__m' );
$this->user->password = Input::get( 'password' );
// The password confirmation will be removed from model
// before saving. This field will be used in Ardent's
// auto validation.
$this->user->password_confirmation = Input::get( 'password_confirmation' );
$this->user->confirmed = Input::get( 'confirm' );
// Permissions are currently tied to roles. Can't do this yet.
//$user->permissions = $user->roles()->preparePermissionsForSave(Input::get( 'permissions' ));
// Save if valid. Password field will be hashed before save
$this->user->save();
if ( $this->user->id )
{
// Save roles. Handles updating.
$this->user->saveRoles(Input::get( 'roles' ));
// Redirect to the new user page
return Redirect::to('admin/users/' . $this->user->id . '/edit')->with('success', Lang::get('admin/users/messages.create.success'));
}
else
{
// Get validation errors (see Ardent package)
$error = $this->user->errors()->all();
return Redirect::to('admin/users/create')
->withInput(Input::except('password'))
->with( 'error', $error );
}
}
我在注册页面上几乎一样,用户创建一个自己的帐户,就像一个魅力。不知怎的,这似乎没有用..
在视图中我添加了这个
<div class="form-group {{{ $errors->has('d__day_of_birth__m') ? 'error' : '' }}}">
<label class="col-md-2 control-label" for="day_of_birth">{{{ Lang::get('form.day_of_birth') }}}</label>
<div class="col-md-10">
<input class="form-control js__birthdaypicker" placeholder="{{{ Lang::get('form.day_of_birth') }}}" type="text" name="day_of_birth" id="day_of_birth" value="{{{ Input::old('day_of_birth', isset($user) ? $user->email : null) }}}"/>
{{{ $errors->first('d__day_of_birth__m', '<span class="help-inline">:message</span>') }}}
</div>
</div>
答案 0 :(得分:0)
在html中,您将输入day_of_birth
命名为d__day_of_birth__m
。