Add Blueprint/formPrint compatibility to BootstrapRenderer#111
Draft
Add Blueprint/formPrint compatibility to BootstrapRenderer#111
Conversation
This change enables the {formPrint} Latte macro to work with BootstrapForm.
Previously, using {formPrint} with BootstrapForm would fail because:
1. BootstrapRenderer::attachForm() only accepted BootstrapForm
2. The renderer directly accessed $this->form->showValidation which
doesn't exist on regular Form objects
3. renderControl() and renderLabel() didn't handle string returns from
getControl()/getLabel() which Blueprint's dummy controls return
Changes:
- Updated attachForm() to accept Form instead of BootstrapForm
- Added isShowValidation() helper method that safely checks the property
- Updated renderControl() to handle string returns for Blueprint compatibility
- Updated renderLabel() to handle string returns for Blueprint compatibility
- Added comprehensive test suite for Blueprint/formPrint functionality
Fixes: #63
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds compatibility with Nette's
Blueprint::latte()functionality and the{formPrint}macro by makingBootstrapRendererwork with regularForminstances, not justBootstrapForm.Key Changes
attachForm()parameter type fromBootstrapFormtoFormto accept any form instancegetControl()andgetLabel()methods, which Blueprint uses instead of Html objectsisShowValidation()helper method that safely checks if the form is aBootstrapFormbefore accessing validation properties, returningfalsefor regular formsrenderLabel()return type toHtml|stringto accommodate Blueprint's string-based renderingImplementation Details
BootstrapForminstance, preventing errors when used with regular formsBootstrapFormusageBlueprintCompatibilityTest) covering various scenarios including different render modes, Bootstrap versions, and form typesTesting
Added 13 new tests verifying:
https://claude.ai/code/session_017S8dLXAbfF5iXKzYq8ADt2