本文整理匯總了PHP中Model\User::form方法的典型用法代碼示例。如果您正苦於以下問題:PHP User::form方法的具體用法?PHP User::form怎麽用?PHP User::form使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Model\User
的用法示例。
在下文中一共展示了User::form方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: actionDefault
/**
* Default action with registration form.
*
* @access public
* @return View
* @since 1.0.0
* @version 2.1.0-dev
*/
public function actionDefault()
{
// if user is logged, redirect to main page
if (UserModel::isLogged()) {
Route::factory('home')->redirectTo();
}
$this->setTitle(__('Register Your account'));
$this->setKeywords(__('register account,login,email,password'));
/* @var $oConfig ModelFormConfig */
$oConfig = ModelFormConfig::factory();
$oConfig->noReload();
$oConfig->setFieldsRestriction(['login', 'email', 'password']);
$oUser = new UserModel();
$oModelForm = $oUser->form('register', $oConfig);
/* @var $oModelForm \ModelForm\User */
$oForm = $oModelForm->generate();
// if form is submitted and is valid
if ($oForm->isSubmittedAndValid()) {
$this->sendActivationCode($oForm->get('password_confirm'), $oUser);
$sMessage = __('Your account has been registered successfully. Activation link has been sent to your mailbox. Click it to make the final activation.');
Session::flash(Router::getCurrentUrl(), $sMessage);
}
// return registration View
return View::factory('user/frontend/register')->bind('oForm', $oForm);
}