-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
44 lines (33 loc) · 1.24 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
require 'vendor/autoload.php';
$app = new \atk4\ui\App('App');
$app->initLayout('Centered');
$app->title = 'Login';
$layout = $app->layout;
$layout->set('title', 'La casa de los videojuegos - Administración');
$app->add('Header')->set('Inicio de sesión');
$form = $app->add(new \atk4\ui\Form());
$form->setModel(new \atk4\data\Model());
$gc = $form->addGroup('Correo electrónico');
$gc->addField('email', ['caption' => '[email protected]']);
$gp = $form->addGroup('Password');
$gp->addField('password', ['caption' => '*********'], ['type' => 'password']);
$form->buttonSave->set('Iniciar sesión');
$form->buttonSave->icon = 'unlock alternate';
$form->onSubmit(function ($f) {
$errors = [];
foreach (['email', 'password'] as $field) {
if (!$f->model[$field]) {
$errors[] = $f->error($field, 'Campo obligatorio');
}
}
if($errors) {
return $errors;
} else {
if($f->model['email'] != '[email protected]' || $f->model['password'] != 'ch25mi29n?') {
return (new \atk4\ui\jsNotify('El correo electrónico y/o password ingresados son incorrectos.'))->setColor('red');
} else {
return [new \atk4\ui\jsExpression( 'window.location.href = "dashboard.php"' )];
}
}
});