Skip to content

Feat - Add configurable table question type#31

Open
RomainLvr wants to merge 12 commits into
mainfrom
feat/configurable-table-question
Open

Feat - Add configurable table question type#31
RomainLvr wants to merge 12 commits into
mainfrom
feat/configurable-table-question

Conversation

@RomainLvr

Copy link
Copy Markdown

Checklist before requesting a review

Please delete options that are not relevant.

  • I have performed a self-review of my code.
  • I have added tests (when available) that prove my fix is effective or that my feature works.
  • I have updated the CHANGELOG with a short functional description of the fix or new feature.
  • This change requires a documentation update.

Description

  • It fixes !43740
  • Here is a brief description of what this PR does

Adds a new Table question type to the plugin, letting form
designers collect tabular data with fully configurable columns.

Changes

  • Configurable columns: each column has a label, a cell type (reusing a compatible core question type), an optional item type, and a "required" flag.
  • Configurable rows: min/max row count, with end users adding/removing rows dynamically.
  • End-user input: renders an editable table; select-based cells (users, items, devices…) use select2.
  • Answer display: stored answers are rendered back as a clean read-only table.
  • Required-column validation:
    • Server-side (authoritative) via QuestionTypeValidationInterface — blocks submission when a filled row leaves a required cell empty.
    • Client-side — highlights only the offending cells (red border + message) and blocks the submit before the server round-trip.
  • Disabled by default; enabled from the plugin configuration like the other advanced question types.

Tests

  • Unit + integration tests for config (de)serialization, compatible types, cell rendering, editor/helpdesk rendering, and required-column validation across every compatible column type.

Screenshots (if appropriate):

image image image image

Fill form exemple :

image image

@RomainLvr RomainLvr requested review from ccailly and stonebuzz June 24, 2026 09:59
@RomainLvr RomainLvr self-assigned this Jun 24, 2026
Comment thread public/css/advancedforms.css Outdated
Comment thread src/Model/QuestionType/TableQuestion.php Outdated
Comment thread public/js/modules/AfTableQuestionConfig.js Outdated
Comment thread public/js/modules/AfTableQuestionConfig.js Outdated
Comment thread tests/Model/QuestionType/TableQuestionValidationTest.php
@RomainLvr RomainLvr requested a review from stonebuzz June 26, 2026 08:34
Comment thread src/Model/QuestionType/TableQuestion.php Outdated
Comment thread src/Model/QuestionType/TableQuestionConfig.php
Comment thread tests/Model/QuestionType/TableQuestionValidationTest.php
Comment thread tests/Model/QuestionType/TableQuestionValidationTest.php
Comment thread tests/Model/QuestionType/TableQuestionConfigTest.php
@RomainLvr

Copy link
Copy Markdown
Author

@ccailly suggested making the column limit a validation criterion (like those already present in Forms) rather than managing it manually. The benefits would be:

  • Easier and more robust
  • Useful in other situations to have this new criterion

@stonebuzz stonebuzz added documentation Improvements or additions to documentation need documentation enhancement New feature or request and removed documentation Improvements or additions to documentation labels Jun 29, 2026
use GlpiPlugin\Advancedforms\Model\QuestionType\TableQuestionConfig;
use GlpiPlugin\Advancedforms\Tests\AdvancedFormsTestCase;

final class TableQuestionValidationTest extends AdvancedFormsTestCase

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Missing test for validateExtraDataInput()

We need two test cases (at least): one confirming the method accepts max_rows=50, and one confirming it rejects max_rows=51.

@ccailly

ccailly commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

@ccailly suggested making the column limit a validation criterion (like those already present in Forms) rather than managing it manually. The benefits would be:

* Easier and more robust

* Useful in other situations to have this new criterion

In addition to avoiding the need to redevelop the line count validation system, adding conditions based on the number of lines will also allow users to set visibility conditions based on the number of lines.

@Rom1-B Rom1-B requested review from Rom1-B and stonebuzz June 30, 2026 10:01
Comment thread src/Model/QuestionType/TableQuestionConfig.php Outdated
Comment thread src/Model/QuestionType/TableQuestionConfig.php Outdated
@Rom1-B Rom1-B requested a review from stonebuzz June 30, 2026 13:29
@stonebuzz

Copy link
Copy Markdown

Awaiting customer validation

@Rom1-B Rom1-B force-pushed the feat/configurable-table-question branch from d1ebeb3 to 0c43bb3 Compare July 2, 2026 10:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request need documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants