Skip to content

fix: honour setDisabled(true) on RadioInput - #128

Merged
dakorpar merged 1 commit into
masterfrom
fix/112-radiolist-disabled
Aug 14, 2026
Merged

fix: honour setDisabled(true) on RadioInput#128
dakorpar merged 1 commit into
masterfrom
fix/112-radiolist-disabled

Conversation

@dakorpar

Copy link
Copy Markdown
Member

Closes #112.

The bug

RadioInput::getControl() decided each item's disabled attribute purely from isValueDisabled(), and that helper returns false whenever the control is disabled as a whole (it only inspects the array form). Nothing else consulted isControlDisabled(), so setDisabled(true) on a radio list rendered markup with no disabled anywhere — the list looked and behaved as fully interactive, contrary to the bool|array signature.

Nette still refused the posted value server-side, so this was a rendering defect rather than a security hole, but the user-visible behaviour was wrong.

The fix

Set the attribute on the fieldset container, which RadioInput already uses as its container prototype:

$container->setAttribute('disabled', $this->isControlDisabled());

This mirrors CheckboxListInput, which puts 'disabled' => $this->isControlDisabled() on its own fieldset — one attribute disables every control inside it, and per-item disabling via setDisabled(['x']) keeps working unchanged.

Tests

tests/Traits/ChoiceInputTraitTest.php carried a test that deliberately pinned this gap (testDisablingTheWholeRadioListIsNotReflectedInTheHtml) so a fix would surface as a failure. That test is replaced by one asserting the correct behaviour, plus:

  • re-enabling with setDisabled(false) drops the attribute again
  • the attribute survives showValidation()
  • exact-HTML assertions in tests/Inputs/RadioInputTest.php for both the wholly-disabled and single-item-disabled cases
  • an E2E case in tests/E2E/FormSubmissionTest.php covering render + rejected post together

make tests (155 tests), make phpstan and make cs all pass.

🤖 Generated with Claude Code

RadioInput::getControl() only ever asked isValueDisabled() per item, and
that helper deliberately returns false when the control is disabled as a
whole, so setDisabled(true) rendered a fully interactive radio list.

Set the attribute on the fieldset container instead, the same way
CheckboxListInput already handles a wholly disabled control — one
attribute disables every radio inside it.

Closes #112

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@codecov

codecov Bot commented Aug 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.05%. Comparing base (104dd03) to head (36900c7).

Additional details and impacted files
@@             Coverage Diff              @@
##             master     #128      +/-   ##
============================================
+ Coverage     96.94%   97.05%   +0.10%     
  Complexity      308      308              
============================================
  Files            25       25              
  Lines           983      984       +1     
============================================
+ Hits            953      955       +2     
+ Misses           30       29       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dakorpar
dakorpar merged commit c9300d6 into master Aug 14, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RadioList ignores setDisabled() for whole control

1 participant