From 29f007e537eb9bc6baebbce4759552407ec0ab0f Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Tue, 4 Mar 2014 10:56:12 +0000 Subject: [PATCH] Comfortable focus setting on login mask * Needs improvement once we have better forms --- application/forms/Authentication/LoginForm.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/application/forms/Authentication/LoginForm.php b/application/forms/Authentication/LoginForm.php index 2d824c591..b4e79cbe8 100644 --- a/application/forms/Authentication/LoginForm.php +++ b/application/forms/Authentication/LoginForm.php @@ -54,9 +54,7 @@ class LoginForm extends Form array( 'required' => true, 'placeholder' => t('Username'), - 'class' => 'autofocus' ) - ); $this->addElement( @@ -67,7 +65,13 @@ class LoginForm extends Form 'required' => true ) ); - + $user = $this->getElement('username'); + // TODO: We need a place to intercept filled forms before rendering + if (isset($_POST['username'])) { + $this->getElement('password')->setAttrib('class', 'autofocus'); + } else { + $user->setAttrib('class', 'autofocus'); + } $this->setSubmitLabel('Login'); }