diff --git a/src/Bridges/FormsLatte/FormMacros.php b/src/Bridges/FormsLatte/FormMacros.php index b0c56834d..0708bf53d 100644 --- a/src/Bridges/FormsLatte/FormMacros.php +++ b/src/Bridges/FormsLatte/FormMacros.php @@ -198,7 +198,7 @@ public function macroNameEnd(MacroNode $node, PhpWriter $writer) $node->content = $parts[1] . $parts[2] . '' . $parts[3]; } elseif ($tagName === 'label') { if ($node->htmlNode->isEmpty) { - $node->content = $parts[1] . 'getLabel()->getHtml() ?>' . $parts[3]; + $node->content = $parts[1] . "{method_exists(\$_input, 'getLabelPart')?'getLabelPart':'getLabel'}()->getHtml() ?>" . $parts[3]; } } elseif ($tagName === 'button') { if ($node->htmlNode->isEmpty) { diff --git a/tests/Forms.Latte/FormMacros.forms.phpt b/tests/Forms.Latte/FormMacros.forms.phpt index c05394939..0e2e49d8a 100644 --- a/tests/Forms.Latte/FormMacros.forms.phpt +++ b/tests/Forms.Latte/FormMacros.forms.phpt @@ -32,7 +32,7 @@ $form->addText('username', 'Username:'); // must have just one textfield to gene $form->addRadioList('sex', 'Sex:', array('m' => 'male', 'f' => 'female')); $form->addSelect('select', NULL, array('m' => 'male', 'f' => 'female')); $form->addTextArea('area', NULL)->setValue('oneaddCheckbox('checkbox', NULL); +$form->addCheckbox('checkbox', 'Checkbox'); $form->addCheckboxList('checklist', 'CheckboxList:', array('m' => 'male', 'f' => 'female')); $form->addSubmit('send', 'Sign in'); $form['my'] = new MyControl; diff --git a/tests/Forms.Latte/expected/FormMacros.forms.html b/tests/Forms.Latte/expected/FormMacros.forms.html index 64491ce02..ca9e00a53 100644 --- a/tests/Forms.Latte/expected/FormMacros.forms.html +++ b/tests/Forms.Latte/expected/FormMacros.forms.html @@ -77,6 +77,8 @@ + + diff --git a/tests/Forms.Latte/expected/FormMacros.forms.phtml b/tests/Forms.Latte/expected/FormMacros.forms.phtml index ffa66537b..babe7fe8e 100644 --- a/tests/Forms.Latte/expected/FormMacros.forms.phtml +++ b/tests/Forms.Latte/expected/FormMacros.forms.phtml @@ -36,7 +36,7 @@ echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin($form = $_form = $_contro {method_exists($_input, 'getLabelPart')?'getLabelPart':'getLabel'}()->attributes() ?>> {method_exists($_input, 'getLabelPart')?'getLabelPart':'getLabel'}()->attributes() ?> ->getLabel()->getHtml() ?> +>{method_exists($_input, 'getLabelPart')?'getLabelPart':'getLabel'}()->getHtml() ?> {method_exists($_input, 'getControlPart')?'getControlPart':'getControl'}()->attributes() ?>> getLabel()) echo $_label ; echo $_form["my"]->getControl() ?> @@ -59,10 +59,10 @@ echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin($form = $_form = $_contro {method_exists($_input, 'getLabelPart')?'getLabelPart':'getLabel'}()->attributes() ?>> {method_exists($_input, 'getLabelPart')?'getLabelPart':'getLabel'}()->attributes() ?> ->getLabel()->getHtml() ?> +>{method_exists($_input, 'getLabelPart')?'getLabelPart':'getLabel'}()->getHtml() ?> +))->attributes() ?>>{method_exists($_input, 'getLabelPart')?'getLabelPart':'getLabel'}()->getHtml() ?> getLabelPart("")) echo $_label->startTag() ?> @@ -74,6 +74,11 @@ echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin($form = $_form = $_contro +getLabelPart("")->attributes() ?> +>{method_exists($_input, 'getLabelPart')?'getLabelPart':'getLabel'}()->getHtml() ?> + items as $key => $label) { ?> @@ -87,10 +92,10 @@ echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin($form = $_form = $_contro {method_exists($_input, 'getLabelPart')?'getLabelPart':'getLabel'}()->attributes() ?>> {method_exists($_input, 'getLabelPart')?'getLabelPart':'getLabel'}()->attributes() ?> ->getLabel()->getHtml() ?> +>{method_exists($_input, 'getLabelPart')?'getLabelPart':'getLabel'}()->getHtml() ?> +))->attributes() ?>>{method_exists($_input, 'getLabelPart')?'getLabelPart':'getLabel'}()->getHtml() ?>
+