Skip to content

Commit

Permalink
DefaultFormRenderer: new methods for rendering elements (#299)
Browse files Browse the repository at this point in the history
  • Loading branch information
bartko-s authored and dg committed Mar 8, 2023
1 parent a326d5f commit 64cdc2d
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/Forms/Rendering/DefaultFormRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ public function renderPairMulti(array $controls): string
}

$control->setOption('rendered', true);
$el = $control->getControl();
$el = $this->renderControlElement($control);
if ($el instanceof Html) {
if ($el->getName() === 'input') {
$el->class($this->getValue("control .$el->type"), true);
Expand All @@ -443,7 +443,7 @@ public function renderPairMulti(array $controls): string
public function renderLabel(Nette\Forms\Control $control): Html
{
$suffix = $this->getValue('label suffix') . ($control->isRequired() ? $this->getValue('label requiredsuffix') : '');
$label = $control->getLabel();
$label = $this->renderLabelElement($control);
if ($label instanceof Html) {
$label->addHtml($suffix);
if ($control->isRequired()) {
Expand Down Expand Up @@ -494,7 +494,7 @@ public function renderControl(Nette\Forms\Control $control): Html
$els = $errors = [];
renderControl:
$control->setOption('rendered', true);
$el = $control->getControl();
$el = $this->renderControlElement($control);
if ($el instanceof Html) {
if ($el->getName() === 'input') {
$el->class($this->getValue("control .$el->type"), true);
Expand All @@ -516,6 +516,20 @@ public function renderControl(Nette\Forms\Control $control): Html
}


/** @return string|Html|null */
protected function renderLabelElement(Nette\Forms\Control $control)
{
return $control->getLabel();
}


/** @return string|Html */
protected function renderControlElement(Nette\Forms\Control $control)
{
return $control->getControl();
}


public function getWrapper(string $name): Html
{
$data = $this->getValue($name);
Expand Down

0 comments on commit 64cdc2d

Please sign in to comment.