Skip to content

Keep rows, cols and multiple off the wrapper div - #211

Merged
flangfeldt merged 1 commit into
masterfrom
fix/reserved-field-meta-wrapper-leak
Sep 13, 2026
Merged

flangfeldt merged 1 commit into
masterfrom
fix/reserved-field-meta-wrapper-leak

Conversation

@rvanbaalen

@rvanbaalen rvanbaalen commented Sep 10, 2026 •

Copy link
Copy Markdown
Member

Closes #210.

rows, cols and multiple now render only on the input, not on the wrapper <div> as well.

Field Wrapper before Wrapper after
Textarea, ['cols' => 30, 'rows' => 4] <div cols="30" rows="4" class="vf__optional"> <div class="vf__optional">
Select, ['multiple' => true] <div multiple="1" class="vf__optional"> <div class="vf__optional">

Cause

Base::__initializeMeta() renames $key to "field" . $key, routes the value, then calls unset($this->__meta[$key]) — removing "fieldcols", which never existed. The original "cols" survives and __getMetaString() prints it on the wrapper.

Only the unprefixed form is hit; fieldcols skips the rename so its unset matches. Unprefixed is the intended form here — $__reservedfieldmeta exists to route these three keys, Element::setClass() reads $meta["multiple"] unprefixed to pick vf__one or vf__multiple, and examples/textarea.php documents "cols" / "rows".

Fix

Capture the key before the rename, unset that one.

That leaves __getMetaString()'s second guard with nothing to catch, and it was wrong anyway:

if (! in_array($key, array_merge($this->__reservedmeta, $this->__fieldmeta))) {

array_merge contributes __fieldmeta's values, not its keys, so a wrapper attribute vanished whenever an unrelated field meta value equalled its name — ['fieldplaceholder' => 'class'] erased the wrapper's own class="vf__optional". Merge dropped.

array_keys() is not a valid replacement: __fieldmeta always carries a class key, so it would suppress class on every wrapper.

Tests

955 tests, 1765 assertions, green. Three added, each confirmed to fail on master before the fix:

  • TextareaTest::unprefixedRowsAndColsStayOffTheWrapper
  • SelectTest::multipleMetaStaysOffTheWrapper
  • ElementTest::wrapperAttributesSurviveAFieldMetaValueMatchingTheirName

Each asserts both halves — gone from the wrapper, still on the input — so the routing cannot be dropped to make them pass. ElementTest gained use HtmlAssertionsTrait; it had no DOM helper.

For reviewers

The __initializeMeta() docblock above the changed loop said $meta["labelstyle"] becomes $__fieldmeta["style"]. It becomes $__labelmeta["style"]. Corrected in place — say so if you want it split out.

PR #209 fixes a different defect in the same area (Textarea appending its defaults). No conflict. Textareas on this branch still render rows="5 4", so the new textarea test asserts a clean wrapper rather than an exact rows value.

__initializeMeta renamed $key to "field" . $key before unsetting it, so
the original entry survived in __meta and rendered on the wrapper. With
that corrected, __getMetaString no longer needs to filter against
__fieldmeta, which it did by value rather than by key.

Closes #210
@github-actions

Copy link
Copy Markdown
Contributor

Coverage report for commit: 3f71c47
File: coverage.xml

Cover ┌─────────────────────────┐ Freq.
   0% │ ░░░░░░░░░░░░░░░░░░░░░░░ │  0.0%
  10% │ ░░░░░░░░░░░░░░░░░░░░░░░ │  0.0%
  20% │ ░░░░░░░░░░░░░░░░░░░░░░░ │  0.0%
  30% │ ░░░░░░░░░░░░░░░░░░░░░░░ │  0.0%
  40% │ ░░░░░░░░░░░░░░░░░░░░░░░ │  0.0%
  50% │ ░░░░░░░░░░░░░░░░░░░░░░░ │  0.0%
  60% │ ░░░░░░░░░░░░░░░░░░░░░░░ │  0.0%
  70% │ ░░░░░░░░░░░░░░░░░░░░░░░ │  0.0%
  80% │ ░░░░░░░░░░░░░░░░░░░░░░░ │  0.0%
  90% │ ░░░░░░░░░░░░░░░░░░░░░░░ │  0.0%
 100% │ ███████████████████████ │ 100.0%
      └─────────────────────────┘
 *Legend:* █ = Current Distribution 
Summary - Lines: 99.89% | Methods: 99.38%
FilesLinesMethodsBranches
classes/ValidFormBuilder
   Area.php100.00%100.00%100.00%
   Base.php99.26%97.50%100.00%
   Button.php100.00%100.00%100.00%
   Checkbox.php100.00%100.00%100.00%
   ClassDynamic.php100.00%100.00%100.00%
   Collection.php100.00%100.00%100.00%
   Comparison.php100.00%100.00%100.00%
   Condition.php98.51%88.89%100.00%
   Element.php100.00%100.00%100.00%
   FieldValidator.php100.00%100.00%100.00%
   Fieldset.php100.00%100.00%100.00%
   File.php100.00%100.00%100.00%
   Group.php100.00%100.00%100.00%
   GroupField.php100.00%100.00%100.00%
   Hidden.php100.00%100.00%100.00%
   MultiField.php100.00%100.00%100.00%
   Navigation.php100.00%100.00%100.00%
   Note.php100.00%100.00%100.00%
   Page.php100.00%100.00%100.00%
   Paragraph.php100.00%100.00%100.00%
   Password.php100.00%100.00%100.00%
   Select.php100.00%100.00%100.00%
   SelectGroup.php100.00%100.00%100.00%
   SelectOption.php100.00%100.00%100.00%
   StaticText.php100.00%100.00%100.00%
   Text.php100.00%100.00%100.00%
   Textarea.php100.00%100.00%100.00%
   ValidForm.php100.00%100.00%100.00%
   ValidWizard.php100.00%100.00%100.00%
   Validator.php100.00%100.00%100.00%

🤖 comment via lucassabreu/comment-coverage-clover

@rvanbaalen rvanbaalen self-assigned this Sep 10, 2026
@flangfeldt
flangfeldt merged commit 16913bc into master Sep 13, 2026
6 checks passed
@flangfeldt
flangfeldt deleted the fix/reserved-field-meta-wrapper-leak branch September 13, 2026 19:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rows, cols and multiple render on the wrapper div as well as on the input

2 participants