forked from SymfonyCasts/symfony-ux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpre-turbo-add-log-in-helper-links.diff
61 lines (58 loc) · 2.57 KB
/
pre-turbo-add-log-in-helper-links.diff
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
diff --git a/assets/controllers/form-filler_controller.js b/assets/controllers/form-filler_controller.js
new file mode 100644
index 0000000..a4d4bd2
--- /dev/null
+++ b/assets/controllers/form-filler_controller.js
@@ -0,0 +1,10 @@
+import { Controller } from 'stimulus';
+
+export default class extends Controller {
+ static targets = ['input'];
+
+ fillInField(event) {
+ event.preventDefault();
+ this.inputTarget.value = event.currentTarget.textContent;
+ }
+}
diff --git a/templates/security/login.html.twig b/templates/security/login.html.twig
index 1180589..3fe97af 100644
--- a/templates/security/login.html.twig
+++ b/templates/security/login.html.twig
@@ -15,20 +15,34 @@
</div>
{% endif %}
- <div class="form-group">
+ <div class="form-group" data-controller="form-filler">
<h1 class="h3 mb-3 font-weight-normal" style="margin-top: 100px;">Welcome back!</h1>
<label for="inputEmail">Email</label>
- <input type="email" value="{{ last_username }}" name="email" id="inputEmail" class="form-control" required autofocus>
+ <input
+ type="email"
+ value="{{ last_username }}"
+ data-form-filler-target="input"
+ name="email"
+ id="inputEmail"
+ class="form-control"
+ required autofocus>
<small class="form-text text-muted">
- (try email <code>[email protected]</code>)
+ (try email <code><span style="cursor: pointer" data-action="click->form-filler#fillInField">[email protected]</span></code>)
</small>
</div>
- <div class="form-group mt-3">
+ <div class="form-group mt-3" data-controller="form-filler">
<label for="inputPassword">Password</label>
- <input type="password" name="password" id="inputPassword" class="form-control" required>
+ <input
+ type="password"
+ data-form-filler-target="input"
+ name="password"
+ id="inputPassword"
+ class="form-control"
+ required
+ >
<small class="form-text text-muted">
- (try password <code>buy</code>)
+ (try password <code><span style="cursor: pointer" data-action="click->form-filler#fillInField">buy</span></code>)
</small>
</div>