fix: Resolve Twig error when creating campaign conditions on custom object fields#386
Open
minholi wants to merge 2 commits into
Open
fix: Resolve Twig error when creating campaign conditions on custom object fields#386minholi wants to merge 2 commits into
minholi wants to merge 2 commits into
Conversation
escopecz
approved these changes
Jun 26, 2026
escopecz
left a comment
Contributor
There was a problem hiding this comment.
The code changes make sense 👍
…hip object Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
Problem
When adding a campaign condition based on a custom object field value, Mautic threw a critical runtime error:
Twig\Error\RuntimeError: "Neither the property "form" nor one of the methods "form()",
"getform()"/"isform()"/"hasform()" or "__call()" exist and have public access in
class "Symfony\Component\Form\FormView"."
at ...FormBundle/Resources/views/FormTheme/FieldValueCondition/
_campaignevent_form_field_value_widget.html.twig line 4
Root cause
CampaignSubscriber::onCampaignBuild() registered the campaign condition with formTheme pointing to
@MauticForm/FormTheme/FieldValueCondition/_campaignevent_form_field_value_widget.html.twig. That template belongs to
Mautic's core FormBundle and is designed for its own lead-form "Field Value Condition" — it tries to render {{
form_row(form.form) }} (a "form" selector field), which does not exist in this plugin's
CampaignConditionFieldValueType.
Fix
Mautic's FormBundle template.
- Added the required {% block _campaignevent_properties_row %} wrapper (the ID-based block Symfony looks for when
rendering the properties row of the campaignevent form)
- Changed {{ form_row(field) }} → {{ form_row(form.field) }} (children must be accessed via form.* inside a form
theme block)
- Added {{ form_widget(form.customObjectId) }} to ensure the hidden field is included in the form submission
- Removed stray PHP tags () that had no effect in a Twig file