gpt4 book ai didi

php - 为 Zizaco/confide 添加额外字段会导致错误

转载 作者:行者123 更新时间:2023-11-30 00:53:17 25 4
gpt4 key购买 nike

您好,我正在使用 Laravel(这个框架的新手)和 Zizaco/Confide 包。我已经根据自己的需要和偏好进行了很多编辑,但我似乎无法解决添加新输入字段以创建新用户作为管理员的问题

see form.day_of_birth field

enter image description here

错误表明该字段未填充(尽管已填充)(我已检查在屏幕上提交后打印 session 数组)

在 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 );
}
}

我在注册页面上几乎有相同的内容,供用户创建自己的帐户,这就像一个魅力。不知怎的,这里似乎不起作用..

在 View 中我添加了这个

                 <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>

最佳答案

在 html 中,您将输入命名为 day_of_birth 而不是 d__day_of_birth__m

关于php - 为 Zizaco/confide 添加额外字段会导致错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20792776/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com