diff --git a/src/Forms/Rendering/DefaultFormRenderer.php b/src/Forms/Rendering/DefaultFormRenderer.php index b168bef5b..d2d73133b 100644 --- a/src/Forms/Rendering/DefaultFormRenderer.php +++ b/src/Forms/Rendering/DefaultFormRenderer.php @@ -450,6 +450,20 @@ public function renderControl(Nette\Forms\IControl $control): Html $description = $this->getValue('control requiredsuffix') . $description; } + $el = $this->doRenderControl($control); + + if ($nextTo = $control->getOption('nextTo')) { + $nextControl = $control->getForm()->getComponent($nextTo); + $nextEl = $this->doRenderControl($nextControl); + return $body->setHtml($el . $nextEl . $description . $this->renderErrors($control) . $this->renderErrors($nextControl)); + } + + return $body->setHtml($el . $description . $this->renderErrors($control)); + } + + + private function doRenderControl(Nette\Forms\IControl $control) + { $control->setOption('rendered', true); $el = $control->getControl(); if ($el instanceof Html) { @@ -458,7 +472,7 @@ public function renderControl(Nette\Forms\IControl $control): Html } $el->class($this->getValue('control .error'), $control->hasErrors()); } - return $body->setHtml($el . $description . $this->renderErrors($control)); + return $el; } diff --git a/tests/Forms/Forms.renderer.1.expect b/tests/Forms/Forms.renderer.1.expect index a87dbecee..197c414eb 100644 --- a/tests/Forms/Forms.renderer.1.expect +++ b/tests/Forms/Forms.renderer.1.expect @@ -93,13 +93,7 @@