08/11/2013 9:41am

PHP | Problem - Cannot login error, custom login form extension on MemberLoginForm


class CustomLoginForm extends MemberLoginForm

{
function __construct($controller, $name, $checkCurrentUser = true)
{

if($checkCurrentUser && Member::currentUser() && Member::logged_in_session_exists())
{
$fields = new FieldList(
new HiddenField("AuthenticationMethod", null, $this->authenticator_class, $this)
);
$logoutBtn = new FormAction("logout", _t('Member.BUTTONLOGINZZ', "Log Out"));
$logoutBtn->addExtraClass('btn purple_gradient purple_border');
$actions = new FieldList(
$logoutBtn
);
}
else
{
$emailFld = new TextField("Email", '', Session::get('SessionForms.MemberLoginForm.Email'), null, $this);
$emailFld->setAttribute('placeholder','Email adres');

$passwordFld = new PasswordField("Password", '');
$passwordFld->setAttribute('placeholder','Wachtwoord');

$fields = new FieldList(
new HiddenField("AuthenticationMethod", null, $this->authenticator_class, $this),
$emailFld,
$passwordFld,
new CheckboxField(
"Remember",
"Herriner mij"
)
);
$loginBtn = new FormAction('dologin', _t('Member.BUTTONLOGINZZ', "Log in"));
$loginBtn->addExtraClass('btn purple_gradient purple_border');
$actions = new FieldList(
$loginBtn,
new LiteralField(
'forgotPassword',
'<p id="ForgotPassword"><a href="Security/lostpassword">' . "Ik ben mijn wachtwoord vergeten" . '</a></p>'
)
);

}
$this->setFormMethod('POST', true);
$this->setValidator(new RequiredFields('Email', 'Password'));

Form::__construct($controller, $name, $fields, $actions);
}
public function dologin($data)
{
if($this->performLogin($data))
{
$this->redirectByGroup($data);
}
else
{
$this->controller->redirect(Director::baseURL() . '/');
Utils::promptError('De login informatie die u invulde is incorrect', '[CustomLoginForm:doLogin1]');
}
}

.....


}


Post Comment