File tree 2 files changed +5
-6
lines changed
2 files changed +5
-6
lines changed Original file line number Diff line number Diff line change @@ -337,7 +337,10 @@ public function getHtmlId()
337
337
{
338
338
if (!isset ($ this ->control ->id )) {
339
339
$ form = $ this ->getForm ();
340
- $ this ->control ->id = sprintf (self ::$ idMask , $ this ->lookupPath (), $ form ->getName ());
340
+ $ prefix = $ form instanceof Nette \Application \UI \Form || $ form ->getName () === null
341
+ ? ''
342
+ : $ form ->getName () . '- ' ;
343
+ $ this ->control ->id = sprintf (self ::$ idMask , $ prefix . $ this ->lookupPath ());
341
344
}
342
345
return $ this ->control ->id ;
343
346
}
Original file line number Diff line number Diff line change @@ -40,17 +40,13 @@ test(function () {
40
40
41
41
42
42
test (function () {
43
- Nette \Forms \Controls \BaseControl::$ idMask = 'frm-%s-%s ' ;
44
-
45
43
$ form = new Form ;
46
44
$ input = $ form ->addText ('name ' );
47
- Assert::same ('frm-name- ' , $ input ->getHtmlId ());
45
+ Assert::same ('frm-name ' , $ input ->getHtmlId ());
48
46
});
49
47
50
48
51
49
test (function () {
52
- Nette \Forms \Controls \BaseControl::$ idMask = 'frm-%2$s-%1$s ' ;
53
-
54
50
$ form = new Form ('signForm ' );
55
51
$ input = $ form ->addText ('name ' );
56
52
Assert::same ('frm-signForm-name ' , $ input ->getHtmlId ());
You can’t perform that action at this time.
0 commit comments