Skip to content

fixed problems with * for required#1673

Merged
mambax7 merged 3 commits into
XOOPS:masterfrom
ggoffy:master
Mar 25, 2026
Merged

fixed problems with * for required#1673
mambax7 merged 3 commits into
XOOPS:masterfrom
ggoffy:master

Conversation

@ggoffy
Copy link
Copy Markdown
Contributor

@ggoffy ggoffy commented Mar 25, 2026

Summary by CodeRabbit

  • Bug Fixes
    • Required-field markers on forms now appear only for fields that are actually required, across both caption layouts, so visual indicators correctly reflect mandatory inputs.
  • Tests
    • Added unit tests validating presence/absence of the caption marker for required and non-required fields in both caption layout variations.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 25, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 8d844a37-004d-4681-9b26-fc44fe3af7f9

📥 Commits

Reviewing files that changed from the base of the PR and between 21c56b8 and a4ebadf.

📒 Files selected for processing (1)
  • tests/unit/htdocs/class/xoopsforms/XoopsThemeFormTest.php

Walkthrough

The legacy form renderer's renderThemeForm() now outputs the required-field marker (<span class="caption-marker">*</span>) only when the element's isRequired() is true, applied to both caption rendering branches (normal caption cell and no-colspan caption).

Changes

Cohort / File(s) Summary
Form Renderer
htdocs/class/xoopsform/renderer/XoopsFormRendererLegacy.php
Emits the required-field marker only when $ele->isRequired() is true; conditional applied in both caption rendering paths (standard caption cell and nocolspan caption).
Unit Tests
tests/unit/htdocs/class/xoopsforms/XoopsThemeFormTest.php
Added four PHPUnit tests verifying presence/absence of the caption marker for required vs non-required elements, duplicated for setNocolspan(true) cases.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 10.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fixed problems with * for required' directly addresses the main change: conditional rendering of the required-field marker based on element requirements.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 25, 2026

Codecov Report

❌ Patch coverage is 0% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 19.19%. Comparing base (3ee60fa) to head (a4ebadf).
⚠️ Report is 264 commits behind head on master.

Files with missing lines Patch % Lines
...ass/xoopsform/renderer/XoopsFormRendererLegacy.php 0.00% 5 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             master    #1673       +/-   ##
=============================================
+ Coverage          0   19.19%   +19.19%     
- Complexity        0     7450     +7450     
=============================================
  Files             0      620      +620     
  Lines             0    39087    +39087     
=============================================
+ Hits              0     7501     +7501     
- Misses            0    31586    +31586     

☔ View full report in Codecov by Sentry.
📢 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@htdocs/class/xoopsform/renderer/XoopsFormRendererLegacy.php`:
- Around line 659-661: Fix the PSR-12 indentation in the colspan branch of
XoopsFormRendererLegacy by replacing tabs with spaces to match surrounding code
formatting around the conditional that appends the required marker (the
$ele->isRequired() check that adds '<span class="caption-marker">*</span>' to
$ret); locate the colspan branch in class XoopsFormRendererLegacy and adjust
indentation for that if-block so it uses the same space-based indentation as the
other branch.
- Around line 645-647: The new conditional that appends the required asterisk
uses tab characters instead of the project's PSR-12 space indentation; update
the indentation in the XoopsFormRendererLegacy class around the block that
checks $ele->isRequired() and appends to $ret so spaces are used to match
surrounding code (preserve the logic that adds '<span
class="caption-marker">*</span>' only when $ele->isRequired() is true).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 87ad059c-b6e4-4f4d-8a20-e4aeeb5b9208

📥 Commits

Reviewing files that changed from the base of the PR and between 4327c1f and b0b0149.

📒 Files selected for processing (1)
  • htdocs/class/xoopsform/renderer/XoopsFormRendererLegacy.php

Comment thread htdocs/class/xoopsform/renderer/XoopsFormRendererLegacy.php Outdated
Comment thread htdocs/class/xoopsform/renderer/XoopsFormRendererLegacy.php Outdated
@mambax7 mambax7 requested a review from Copilot March 25, 2026 21:30
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes the legacy theme form renderer so the required-field * marker is only shown for elements that are actually required, improving correctness of form UI output.

Changes:

  • Wrap required * caption marker output in an isRequired() conditional (for both normal and nocolspan rendering paths).

Comment on lines +645 to +647
if ($ele->isRequired()) {
$ret .= '<span class="caption-marker">*</span>';
}
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Newly added block is indented with tabs, which breaks the file’s PSR-12/space-based indentation and makes diffs noisy. Please replace the tab indentation with spaces to match surrounding code.

Copilot uses AI. Check for mistakes.
Comment on lines +659 to +661
if ($ele->isRequired()) {
$ret .= '<span class="caption-marker">*</span>';
}
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This added if ($ele->isRequired()) block uses tab indentation; please use spaces so indentation matches surrounding code style.

Copilot uses AI. Check for mistakes.
Comment on lines 642 to +647
if (($caption = $ele->getCaption()) != '') {
$ret .= '<div class="xoops-form-element-caption' . ($ele->isRequired() ? '-required' : '') . '">';
$ret .= '<span class="caption-text">' . $caption . '</span>';
$ret .= '<span class="caption-marker">*</span>';
if ($ele->isRequired()) {
$ret .= '<span class="caption-marker">*</span>';
}
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change alters the HTML output for theme forms (required * marker now conditional). There are existing unit tests for XoopsThemeForm::render(); please add/adjust tests to assert that caption-marker is present only for required elements and absent for non-required ones, to prevent regressions.

Copilot generated this review using guidance from repository custom instructions.
…elements

Add 4 tests to XoopsThemeFormTest verifying that the caption-marker asterisk
span is rendered only for required elements and absent for non-required ones,
covering both the normal and nocolspan rendering paths.
@sonarqubecloud
Copy link
Copy Markdown

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@mambax7 mambax7 merged commit a402658 into XOOPS:master Mar 25, 2026
16 of 17 checks passed
@mambax7
Copy link
Copy Markdown
Collaborator

mambax7 commented Mar 25, 2026

@ggoffy Thank you!

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.

3 participants