IMPR: AJAX processing

This commit is contained in:
Tony Air 2024-02-02 19:15:24 +02:00
parent a81011feb2
commit cd78ad1f9e

View File

@ -7,6 +7,7 @@ use SilverStripe\Control\Director;
use SilverStripe\Control\HTTPRequest;
use SilverStripe\Core\Extension;
use SilverStripe\Core\Injector\Injector;
use SilverStripe\Forms\Form;
use SilverStripe\Security\MemberAuthenticator\MemberAuthenticator;
use SilverStripe\Security\Security;
use SilverStripe\View\SSViewer;
@ -24,12 +25,23 @@ class AjaxControllerEx extends Extension
'passwordsent',
];
private static function _makeAllFieldsRequired(Form $form)
{
$fields = $form->Fields();
foreach ($fields as $f) {
$f
->setAttribute('required', 'required')
->addExtraClass('required');
}
}
public function LoginFormEx()
{
$ctrl = $this->owner;
/* @var Form $form */
$form = $ctrl->LoginForm();
self::_makeAllFieldsRequired($form);
//$form->addExtraClass('ajax-form');
$form->setLegend('Sign in to your service account');
@ -52,6 +64,7 @@ class AjaxControllerEx extends Extension
->getLostPasswordHandler($ctrl->Link())
->lostPasswordForm();
self::_makeAllFieldsRequired($form);
$form->addExtraClass('ajax-form');
$form->setLegend('Restore your password');