File tree Expand file tree Collapse file tree 2 files changed +5
-6
lines changed Expand file tree Collapse file tree 2 files changed +5
-6
lines changed Original file line number Diff line number Diff line change @@ -337,7 +337,10 @@ public function getHtmlId()
337337 {
338338 if (!isset ($ this ->control ->id )) {
339339 $ 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 ());
341344 }
342345 return $ this ->control ->id ;
343346 }
Original file line number Diff line number Diff line change @@ -40,17 +40,13 @@ test(function () {
4040
4141
4242test (function () {
43- Nette \Forms \Controls \BaseControl::$ idMask = 'frm-%s-%s ' ;
44-
4543 $ form = new Form ;
4644 $ input = $ form ->addText ('name ' );
47- Assert::same ('frm-name- ' , $ input ->getHtmlId ());
45+ Assert::same ('frm-name ' , $ input ->getHtmlId ());
4846});
4947
5048
5149test (function () {
52- Nette \Forms \Controls \BaseControl::$ idMask = 'frm-%2$s-%1$s ' ;
53-
5450 $ form = new Form ('signForm ' );
5551 $ input = $ form ->addText ('name ' );
5652 Assert::same ('frm-signForm-name ' , $ input ->getHtmlId ());
You can’t perform that action at this time.
0 commit comments