Section functionality
Add Section functionality to Nextcloud Forms
Description
This PR adds a new "Section" element type to Nextcloud Forms that acts as a visual separator to group fields logically, without affecting data storage, validation, or submission logic.
Functional Requirements
1. Section Creation
- New "Section" element type in the form editor
- Only parameter: section name (title) visible to users
2. Editor Display
- Sections appear as non-input elements
- Draggable for reordering
- Title displayed in bold/visually distinct style
- No description field for sections
- Bottom separator line for visual distinction
3. Form Filling Display
- Sections display as headings/subheadings at their position
- No influence on validation, mandatory fields, or submission flow
4. Export/View Responses Behavior
- Sections do not affect CSV export or response viewing
- Not stored in user responses
Technical Implementation
Backend Changes
Constants and Types
lib/Constants.php: AddedANSWER_TYPE_SECTION = 'section'constantlib/ResponseDefinitions.php: UpdatedFormsQuestionTypeto include"section"
API Controller (lib/Controller/ApiController.php)
- Section Validation: Sections cannot be required, have options, or file uploads
- Answer Storage: Sections are filtered out from answer storage
- Export Filtering: Sections are excluded from submissions export
- Form Cloning: Sections maintain
isRequired = falsewhen cloning forms
Submission Service (lib/Service/SubmissionService.php)
- Export Data: Sections are filtered out from CSV/Excel export data
- Validation: Sections are ignored during submission validation
Frontend Changes
Components
src/components/Questions/QuestionSection.vue: New component for section renderingsrc/components/Questions/Question.vue: Updated to support section display and editingsrc/models/AnswerTypes.js: Added section type with appropriate icon and labelssrc/models/Constants.ts: AddedANSWER_TYPE_SECTIONconstant
Views
src/views/Create.vue: Updated to pass question type to componentssrc/views/Submit.vue: Updated to filter sections from validation and storagesrc/components/Results/ResultsSummary.vue: Updated to handle sections in results displaysrc/components/Results/Submission.vue: Updated to filter sections from submission data
Testing
Backend Tests
ApiControllerTest.php
testUpdateQuestion_sectionCannotBeRequired(): Verifies sections cannot be made requiredtestNewOption_sectionCannotHaveOptions(): Verifies sections cannot have optionstestUploadFiles_sectionCannotHaveFileUploads(): Verifies sections cannot have file uploadstestGetSubmissions_sectionsAreFilteredOut(): Verifies sections are filtered from exporttestNewSubmission_sectionsAreNotStored(): Verifies sections are not stored in answers
SubmissionServiceTest.php
testGetSubmissionsData_sectionsAreFilteredOut(): Verifies sections are filtered from export datatestValidateSubmission_sectionsAreIgnored(): Verifies sections are ignored in validationtestValidateSubmission_sectionsCannotBeRequired(): Verifies sections cannot be required in validation
Files Changed
Backend Files
lib/Constants.php- Added section constantlib/ResponseDefinitions.php- Updated type definitionslib/Controller/ApiController.php- Added section validation and filteringlib/Service/SubmissionService.php- Added export filtering
Frontend Files
src/components/Questions/QuestionSection.vue- New section componentsrc/components/Questions/Question.vue- Updated for section supportsrc/models/AnswerTypes.js- Added section typesrc/models/Constants.ts- Added section constantsrc/views/Create.vue- Updated component propssrc/views/Submit.vue- Updated validation and storage logicsrc/components/Results/ResultsSummary.vue- Updated results displaysrc/components/Results/Submission.vue- Updated submission handling
Test Files
tests/Unit/Controller/ApiControllerTest.php- Added section teststests/Unit/Service/SubmissionServiceTest.php- Added section tests
Screenshots
Before
- No section functionality available
After
- Section element available in form editor
- Sections display as visual separators with titles
- Sections can be reordered like other form elements
- Sections do not appear in form submissions or exports
Breaking Changes
None. This is a purely additive feature that does not affect existing functionality.
Notes to Reviewers
- All hardcoded string literals have been replaced with constants (
Constants::ANSWER_TYPE_SECTIONon backend,ANSWER_TYPE_SECTIONon frontend) - Sections are completely filtered out from data storage and export to ensure they don't affect existing functionality
- Comprehensive test coverage has been added for all section-related functionality
- The implementation follows Nextcloud Forms coding standards and patterns
Related Issues
This PR implements the section functionality as requested in the technical specification.
Hello there, Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.
We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process.
Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6
Thank you for contributing to Nextcloud and we hope to hear from you soon!
(If you believe you should not receive this message, you can add yourself to the blocklist.)