Adjust LoginForm to suit the "final" form builder implementation
refs #5525
This commit is contained in:
parent
f4ff2c90f2
commit
5da14d3fc5
|
@ -59,7 +59,8 @@ class AuthenticationController extends ActionController
|
|||
}
|
||||
|
||||
$chain = new AuthChain($config);
|
||||
if ($this->view->form->isSubmittedAndValid($this->_request->getParams())) {
|
||||
$request = $this->getRequest();
|
||||
if ($request->isPost() && $this->view->form->isValid($request->getPost())) {
|
||||
$user = new User($this->view->form->getValue('username'));
|
||||
$password = $this->view->form->getValue('password');
|
||||
$backendsTried = 0;
|
||||
|
@ -107,7 +108,7 @@ class AuthenticationController extends ActionController
|
|||
);
|
||||
}
|
||||
$this->view->form->getElement('password')->addError($this->translate('Incorrect username or password'));
|
||||
} elseif (false === $this->view->form->isSubmitted()) {
|
||||
} elseif ($request->isGet()) {
|
||||
$user = new User('');
|
||||
foreach ($chain as $backend) {
|
||||
if ($backend instanceof AutoLoginBackend) {
|
||||
|
|
|
@ -16,51 +16,49 @@ class LoginForm extends Form
|
|||
*/
|
||||
public function init()
|
||||
{
|
||||
$this->setTokenDisabled();
|
||||
$this->setName('form_login');
|
||||
$this->setSubmitLabel('Login');
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Form::createElements()
|
||||
*/
|
||||
public function createElements()
|
||||
public function createElements($formData)
|
||||
{
|
||||
return array(
|
||||
$this->createElement(
|
||||
'text',
|
||||
'username',
|
||||
array(
|
||||
'required' => true,
|
||||
'label' => t('Username'),
|
||||
'placeholder' => t('Please enter your username...'),
|
||||
'required' => true
|
||||
'class' => false === isset($formData['username']) ? 'autofocus' : ''
|
||||
)
|
||||
),
|
||||
$this->createElement(
|
||||
'password',
|
||||
'password',
|
||||
array(
|
||||
'required' => true,
|
||||
'label' => t('Password'),
|
||||
'placeholder' => t('...and your password'),
|
||||
'required' => true
|
||||
'class' => isset($formData['username']) ? 'autofocus' : ''
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Form::applyValues()
|
||||
* @see Form::addSubmitButton()
|
||||
*/
|
||||
public function applyValues(array $values)
|
||||
public function addSubmitButton()
|
||||
{
|
||||
parent::applyValues($values);
|
||||
|
||||
if (isset($values['username'])) {
|
||||
$this->getElement('password')->setAttrib('class', 'autofocus');
|
||||
} else {
|
||||
$this->getElement('username')->setAttrib('class', 'autofocus');
|
||||
}
|
||||
|
||||
return $this;
|
||||
$this->addElement(
|
||||
'submit',
|
||||
'btn_submit',
|
||||
array(
|
||||
'label' => t('Login')
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue