Skip to content

Commit adf0050

Browse files
committed
FormMacros: fixed extraction of elements
1 parent d1c30d6 commit adf0050

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/Bridges/FormsLatte/FormMacros.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -193,20 +193,19 @@ public function macroName(MacroNode $node, PhpWriter $writer)
193193

194194
public function macroNameEnd(MacroNode $node, PhpWriter $writer)
195195
{
196-
preg_match('#^(.*? n:\w+>)(.*)(<[^?].*)\z#s', $node->content, $parts);
197196
$tagName = strtolower($node->htmlNode->name);
198197
if ($tagName === 'form') {
199-
$node->content = $parts[1] . $parts[2] . '<?php echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd($_form, FALSE) ?>' . $parts[3];
198+
$node->innerContent .= '<?php echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd($_form, FALSE) ?>';
200199
} elseif ($tagName === 'label') {
201200
if ($node->htmlNode->isEmpty) {
202-
$node->content = $parts[1] . "<?php echo \$_input->{method_exists(\$_input, 'getLabelPart')?'getLabelPart':'getLabel'}()->getHtml() ?>" . $parts[3];
201+
$node->innerContent = "<?php echo \$_input->{method_exists(\$_input, 'getLabelPart')?'getLabelPart':'getLabel'}()->getHtml() ?>";
203202
}
204203
} elseif ($tagName === 'button') {
205204
if ($node->htmlNode->isEmpty) {
206-
$node->content = $parts[1] . '<?php echo htmlspecialchars($_input->caption) ?>' . $parts[3];
205+
$node->innerContent = '<?php echo htmlspecialchars($_input->caption) ?>';
207206
}
208207
} else { // select, textarea
209-
$node->content = $parts[1] . '<?php echo $_input->getControl()->getHtml() ?>' . $parts[3];
208+
$node->innerContent = '<?php echo $_input->getControl()->getHtml() ?>';
210209
}
211210
}
212211

0 commit comments

Comments
 (0)