Skip to content

Commit 64cdc2d

Browse files
bartko-sdg
authored andcommitted
DefaultFormRenderer: new methods for rendering elements (#299)
1 parent a326d5f commit 64cdc2d

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

src/Forms/Rendering/DefaultFormRenderer.php

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ public function renderPairMulti(array $controls): string
418418
}
419419

420420
$control->setOption('rendered', true);
421-
$el = $control->getControl();
421+
$el = $this->renderControlElement($control);
422422
if ($el instanceof Html) {
423423
if ($el->getName() === 'input') {
424424
$el->class($this->getValue("control .$el->type"), true);
@@ -443,7 +443,7 @@ public function renderPairMulti(array $controls): string
443443
public function renderLabel(Nette\Forms\Control $control): Html
444444
{
445445
$suffix = $this->getValue('label suffix') . ($control->isRequired() ? $this->getValue('label requiredsuffix') : '');
446-
$label = $control->getLabel();
446+
$label = $this->renderLabelElement($control);
447447
if ($label instanceof Html) {
448448
$label->addHtml($suffix);
449449
if ($control->isRequired()) {
@@ -494,7 +494,7 @@ public function renderControl(Nette\Forms\Control $control): Html
494494
$els = $errors = [];
495495
renderControl:
496496
$control->setOption('rendered', true);
497-
$el = $control->getControl();
497+
$el = $this->renderControlElement($control);
498498
if ($el instanceof Html) {
499499
if ($el->getName() === 'input') {
500500
$el->class($this->getValue("control .$el->type"), true);
@@ -516,6 +516,20 @@ public function renderControl(Nette\Forms\Control $control): Html
516516
}
517517

518518

519+
/** @return string|Html|null */
520+
protected function renderLabelElement(Nette\Forms\Control $control)
521+
{
522+
return $control->getLabel();
523+
}
524+
525+
526+
/** @return string|Html */
527+
protected function renderControlElement(Nette\Forms\Control $control)
528+
{
529+
return $control->getControl();
530+
}
531+
532+
519533
public function getWrapper(string $name): Html
520534
{
521535
$data = $this->getValue($name);

0 commit comments

Comments
 (0)