Bind a pluggable text template's contentparams, and report editable where Mendix has none (#928) - #191
Merged
Merged
Conversation
… editable (mendixlabs#928) Two reported bindings that passed `mxcli check`, were written by `exec`, and did nothing. They share one cause: the allow-lists behind MDL-WIDGET01 and MDL-WIDGET07 are widget-type AGNOSTIC. isBuiltinPropName is a single flat list holding both ContentParams and Editable; it answers "is this a real MDL property name anywhere", and both validators read it as "is this valid on THIS widget". The engine then acts on each only for the widget kinds that support it, so the rest is dropped in silence. Bug 1 -- FIXED. A pluggable widget's text-template property imageUrl: '{1}', contentparams: [{1} = PictureUrl] stored a template with an EMPTY parameter list, and mxbuild answered CE0720 "Place holder index 1 is greater than 0, the number of parameter(s)" on the FIRST write -- no describe round-trip needed, contrary to the report. A dynamictext with identical syntax stored the parameter correctly, which is the control that localised it to the pluggable path. The engine took the parameters path only for mxcli's `{AttrName}` spelling, so Mendix's own numeric `{1}` had no route. Both spellings now reach the same stored shape via SetTextTemplateWithClientParams, added to the builder interface and to both implementations. Verified: the reported script is 0 errors and the Image's template holds one parameter bound to Product.PictureUrl, byte-comparable with the dynamictext control. Bug 2 -- NOT FIXABLE AS ASKED, so reported instead (MDL-WIDGET20). Mendix models editability on INPUT widgets only: measured against generated/metamodel, exactly eleven Pages types carry Editability / ConditionalEditabilitySettings -- ten inputs plus DataView -- and not one of the fourteen button types does. There is no field to write, so `editable:` -> Editability on a button cannot be implemented; the issue's own second option is the right one. The warning names conditional visibility, which buttons do support. Both MDL spellings are caught. `editable: 'x'` lowers to `Editable`, the bracket form `editable: [expr]` to `EditableIf` -- and the bracket form is the one that genuinely works on inputs, so leaving it unflagged on a button would have been the more surprising silent drop. The type list is a hand-maintained bridge between MDL and Mendix names, so a test parses the metamodel and fails if that set of eleven changes. Also MDL-WIDGET21, the residue of fixing bug 1: contentparams with no `{N}` placeholder to consume them still had nothing to attach to and were dropped without a word. Neither rule is a .fail.mdl. Both are warnings, so `check` exits 0 and such a fixture would report "negative test unexpectedly passed" -- the trap the Makefile documents above check-mdl, and the one that broke mendixlabs#927's CI. They are demonstrated by a plain .mdl and pinned by unit tests. Verified: reported script 0 errors under mx check (was CE0720); controls with each fix removed reproduce CE0720 and drop all three MDL-WIDGET20 cases; input widgets and 339 shipped examples produce no new warning; `make check-mdl` exits 0; 76 unit packages green; gofmt clean. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013uQvFDd5R4eNqqita59jM8
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.
Fixes both bugs in upstream #928. They turned out to be one bug wearing two hats.
The shared cause
isBuiltinPropName(mdl/executor/widget_engine.go) is a single flat list holding bothContentParamsandEditable, and it backs both validators — MDL-WIDGET01 (pluggable) and MDL-WIDGET07 (static). It answers "is this a real MDL property name anywhere?", and both validators read it as "is this valid on this widget?". The engine then acts on each keyword only for the widget kinds that support it, and drops the rest in silence.Bug 1 — fixed
One correction to the report: it is the first write, not the round-trip. No
describeneeded.The stored BSON localises it — same page, two widgets, same syntax:
dynamictext(control)Text='{1}',Parameters=[2, {ClientTemplateParameter…}]imageUrlText='{1}',Parameters=[2]← emptyThe engine took the parameters path only for mxcli's
{AttrName}convenience spelling, so Mendix's own numeric{1}form had no route at all. Both spellings now reach the same stored shape via a newSetTextTemplateWithClientParamson the builder interface and both implementations. After the fix the Image's template holds one parameter bound toProduct.PictureUrl— identical to the control — andmx checkis 0 errors.Bug 2 — cannot be implemented as asked, so it is now reported
The issue asks for
editable:→Editability/ConditionalEditabilitySettingson a button. There is no such field:PagesActionButtonhasConditionalVisibilitySettingsbut noEditabilityand noConditionalEditabilitySettings.generated/metamodel: exactly 11 Pages types carry editability — CheckBox, DataView, DatePicker, DropDown, FileManager, ImageUploader, InputReferenceSetSelector, RadioButtonGroup, ReferenceSelector, TextArea, TextBox — and none of the 14 button types does.A button has conditional visibility, not editability. So the issue's own second option is the correct one:
MDL-WIDGET20warns and names visibility as the alternative.Two details a reviewer should look at:
editable: 'x'lowers toEditable, but the bracket formeditable: [expr]lowers toEditableIf— and the bracket form is the one that genuinely works on input widgets, so leaving it unflagged on a button would have been the more surprising silent drop. I found the second key by dumping the parsedw.Properties, not by assuming it.editableWidgetTypesis a hand-maintained bridge between MDL type names and Mendix's, soTestEditableWidgetTypesMatchMetamodelparsesgenerated/metamodeland fails if that set of 11 ever changes — in either direction.Also: the residue of fixing Bug 1
contentparamssupplied where no property text carries a{N}placeholder still had nothing to attach to and was dropped without a word.MDL-WIDGET21reports it.Neither rule is a
.fail.mdlBoth are warnings, so
checkexits 0 and such a fixture would reportnegative test unexpectedly passed— the trap the Makefile documents abovecheck-mdl, and the one that broke mendixlabs#927's CI. They are demonstrated by a plain.mdland pinned by unit tests, which is what that note prescribes.Verification
mx checkon 11.13 (was CE0720), with the stored parameter compared against thedynamictextcontrol rather than just counted.editable:and none is flagged.make check-mdlexits 0; 76 unit packages green;gofmt -lclean.Not addressed
The def-mapped texttemplate path (
BuildContext) has no parameter field, so a widget whose text template arrives through a.def.jsonmapping rather than as an explicit property is untouched. The reported case does not go through it, and plumbing it is a larger change — flagging it rather than leaving it to be discovered.Generated by Claude Code