Skip to content

Commit 65b3887

Browse files
committed
{formPrint} more compact output
1 parent 7ae8cf0 commit 65b3887

File tree

5 files changed

+15
-56
lines changed

5 files changed

+15
-56
lines changed

src/Forms/Rendering/DefaultFormRenderer.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,10 @@ private function doRenderErrors(array $errors, bool $control): string
239239
}
240240
$container->addHtml($item);
241241
}
242-
return "\n" . $container->render($control ? 1 : 0);
242+
243+
return $control
244+
? "\n\t" . $container->render()
245+
: "\n" . $container->render(0);
243246
}
244247

245248

tests/Forms.Latte/Runtime.renderBlueprint.phpt

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -52,33 +52,21 @@ Assert::match(
5252
<dt>{label name/}:</dt>
5353
5454
<dd>{input name}
55-
56-
<span class="error" n:ifcontent>
57-
{inputError name}
58-
</span>
59-
</dd>
55+
<span class="error" n:ifcontent>{inputError name}</span></dd>
6056
6157
6258
6359
<dt>{label cont-name/}:</dt>
6460
6561
<dd class="odd">{input cont-name}
66-
67-
<span class="error" n:ifcontent>
68-
{inputError cont-name}
69-
</span>
70-
</dd>
62+
<span class="error" n:ifcontent>{inputError cont-name}</span></dd>
7163
7264
7365
7466
<dt></dt>
7567
7668
<dd>{input agree}
77-
78-
<span class="error" n:ifcontent>
79-
{inputError agree}
80-
</span>
81-
</dd>
69+
<span class="error" n:ifcontent>{inputError agree}</span></dd>
8270
8371
</dl>
8472

tests/Forms/Forms.renderer.1.expect

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,7 @@
1515
<th><label for="frm-age" class="required">Your age:</label></th>
1616

1717
<td><input type="number" name="age" min="10" max="100" id="frm-age" required data-nette-rules='[{"op":":filled","msg":"Enter your age"},{"op":":integer","msg":"Please enter a valid integer."},{"op":":range","msg":"Age must be in range from 10 to 100","arg":[10,100]}]' class="text">
18-
19-
<span class="error">
20-
Enter your age
21-
</span>
22-
</td>
18+
<span class="error">Enter your age</span></td>
2319
</tr>
2420

2521
<tr>
@@ -59,22 +55,14 @@
5955
<th><label for="frm-city">City:</label></th>
6056

6157
<td><input type="text" name="city" id="frm-city" data-nette-rules='[{"op":":equal","rules":[{"op":":filled","msg":"Enter your shipping address"}],"control":"send","arg":true}]' class="text">
62-
63-
<span class="error">
64-
Enter your shipping address
65-
</span>
66-
</td>
58+
<span class="error">Enter your shipping address</span></td>
6759
</tr>
6860

6961
<tr>
7062
<th><label for="frm-country">Country:</label></th>
7163

7264
<td><select name="country" id="frm-country" data-nette-rules='[{"op":":equal","rules":[{"op":":filled","msg":"Select your country"}],"control":"send","arg":true}]'><option value="">Select your country</option><optgroup label="Europe"><option value="CZ">Czech Republic</option><option value="SK">Slovakia</option><option value="GB">United Kingdom</option></optgroup><option value="CA">Canada</option><option value="US">United States</option><option value="?">other</option></select>
73-
74-
<span class="error">
75-
Select your country
76-
</span>
77-
</td>
65+
<span class="error">Select your country</span></td>
7866
</tr>
7967

8068
<tr>
@@ -94,11 +82,7 @@
9482
<th><label for="frm-password" class="required">Choose password:</label></th>
9583

9684
<td><input type="password" name="password" id="frm-password" required data-nette-rules='[{"op":":filled","msg":"Choose your password"},{"op":":minLength","msg":"The password is too short: it must be at least 3 characters","arg":3}]' class="text"><input type="password" name="password2" id="frm-password2" data-nette-rules='[{"op":":valid","rules":[{"op":":filled","msg":"Reenter your password"},{"op":":equal","msg":"Passwords do not match","arg":{"control":"password"}}],"control":"password"}]' class="text"><input type="file" name="avatar" id="frm-avatar" data-nette-rules='[{"op":":fileSize","msg":"The size of the uploaded file can be up to %d% bytes.","arg":%d%},{"op":":filled","rules":[{"op":":image","msg":"Uploaded file is not image"}],"control":"avatar"}]' class="text">
97-
98-
<span class="error">
99-
Reenter your password
100-
</span>
101-
</td>
85+
<span class="error">Reenter your password</span></td>
10286
</tr>
10387

10488
<tr>

tests/Forms/Forms.renderer.2.expect

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,14 @@
1414
<dt><label for="frm-age" class="required">Your age:</label></dt>
1515

1616
<dd class="odd"><input type="number" name="age" min="10" max="100" id="frm-age" required data-nette-rules='[{"op":":filled","msg":"Enter your age"},{"op":":integer","msg":"Age must be numeric value"},{"op":":range","msg":"Age must be in range from 10 to 100","arg":[10,100]}]' value="9.9" class="text is-invalid"> •
17-
18-
<span class="error">
19-
Age must be numeric value
20-
</span>
21-
</dd>
17+
<span class="error">Age must be numeric value</span></dd>
2218

2319

2420

2521
<dt><label for="frm-gender">Your gender:</label></dt>
2622

2723
<dd><select name="gender" id="frm-gender" class="is-invalid"><option style="color: #248bd3" value="m">male</option><option style="color: #e948d4" value="f">female</option></select>
28-
29-
<span class="error">
30-
Please select a valid option.
31-
</span>
32-
</dd>
24+
<span class="error">Please select a valid option.</span></dd>
3325

3426

3527

@@ -82,11 +74,7 @@
8274
<dt><label for="frm-password" class="required">Choose password:</label></dt>
8375

8476
<dd class="multi"><input type="password" name="password" id="frm-password" required data-nette-rules='[{"op":":filled","msg":"Choose your password"},{"op":":minLength","msg":"The password is too short: it must be at least 3 characters","arg":3}]' class="text is-invalid"><input type="password" name="password2" id="frm-password2" data-nette-rules='[{"op":":valid","rules":[{"op":":filled","msg":"Reenter your password"},{"op":":equal","msg":"Passwords do not match","arg":{"control":"password"}}],"control":"password"}]' class="text"> • <small>(at least 3 characters)</small>
85-
86-
<span class="error">
87-
The password is too short: it must be at least 3 characters
88-
</span>
89-
</dd>
77+
<span class="error">The password is too short: it must be at least 3 characters</span></dd>
9078

9179

9280

tests/Forms/Forms.renderer.translate.expect

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,7 @@
1616
<th><label for="frm-password" class="required">PASSWORD</label></th>
1717

1818
<td><input type="password" name="password" id="frm-password" required data-nette-rules='[{"op":":filled","msg":"THIS FIELD IS REQUIRED."},{"op":":minLength","msg":"MINIMAL LENGTH IS %D CHARS","arg":8}]' class="text">
19-
20-
<span class="error">
21-
WEAK PASSWORD
22-
</span>
23-
</td>
19+
<span class="error">WEAK PASSWORD</span></td>
2420
</tr>
2521

2622
<tr>

0 commit comments

Comments
 (0)