Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forms: Cannot call method startTag() / endTag() on Nette\Utils\Html|string when control is checkbox #399

Closed
lulco opened this issue Jul 19, 2023 · 1 comment · Fixed by #401

Comments

@lulco
Copy link
Contributor

lulco commented Jul 19, 2023

Checkbox::getLabel() returns null, so it is weird we can do:

{label checkbox_field}{input checkbox_field}{/label}

it is compiled to:

if ($ʟ_label = $form["checkbox_field"]->getLabel()) {
    echo $ʟ_label->startTag();
}
echo $form["checkbox_field"]->getControl();

if ($ʟ_label) {
    echo $ʟ_label->endTag();
}

If we add stub for Checkbox:getLabel which will return null, condition will be always false, maybe we should change the condition to "instanceof Html"?

@lulco
Copy link
Contributor Author

lulco commented Jul 24, 2023

Update:
Problem is BaseControl::getLabel() returns Html|string|null but compiled code acts like there is still Html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant