Skip to content

feat: configurable description maxLength and boolean required validation fix [3.x]#134

Merged
ManukMinasyan merged 3 commits into3.xfrom
feat/configurable-description-maxlength-boolean-required-fix
Apr 15, 2026
Merged

feat: configurable description maxLength and boolean required validation fix [3.x]#134
ManukMinasyan merged 3 commits into3.xfrom
feat/configurable-description-maxlength-boolean-required-fix

Conversation

@ManukMinasyan
Copy link
Copy Markdown
Collaborator

@ManukMinasyan ManukMinasyan commented Apr 15, 2026

Summary

  • Configurable description maxLength: The description textarea in field and section management forms was hardcoded to 255 characters. Adds separate config keys for fields and sections (both default to 255), so projects needing longer descriptions (e.g. Agreement fields) can increase the limit independently.
  • Boolean required validation fix: Laravel's required rule passes on false, so a "required" checkbox/toggle could be submitted unchecked. Now uses the accepted rule (rejects false/0/null) and markAsRequired() for the visual asterisk without injecting the broken required validation rule.

Config keys

// Field descriptions (stored in JSON settings column -- no DB limit)
'fields' => [
    'description_max_length' => 255,
],

// Section descriptions (stored in VARCHAR(255) column -- increasing beyond 255 requires a migration)
'sections' => [
    'description_max_length' => 255,
],

Changes

File Change
config/custom-fields.php Add fields.description_max_length and sections.description_max_length
src/Filament/Management/Schemas/FieldForm.php Use fields.description_max_length config
src/Filament/Management/Schemas/SectionForm.php Use sections.description_max_length config
src/Filament/Integration/Base/AbstractFormComponent.php markAsRequired() for boolean fields
src/Services/ValidationService.php Add accepted rule for required boolean fields
tests/Feature/Integration/ValidationCapabilitiesTest.php 5 new tests for boolean required validation

Test plan

  • Required checkbox with false -> validation error
  • Required checkbox with true -> passes
  • Required toggle with false -> validation error
  • Required toggle with true -> passes
  • Non-required checkbox with false -> passes (regression guard)
  • Full test suite passes (32/32)
  • Pint clean
  • PHPStan 0 errors

…ion fix

Make the description textarea maxLength configurable via
config('custom-fields.fields.description_max_length') with a 255 default,
allowing longer descriptions for field types like Agreement.

Fix required validation for checkbox/toggle fields: Laravel's `required`
rule passes on `false`, so a required boolean could be submitted unchecked.
Now uses `accepted` rule instead, and `markAsRequired()` for the visual
asterisk without injecting the broken `required` validation rule.
Copilot AI review requested due to automatic review settings April 15, 2026 16: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

Adds configurability for the management UI description length limit, and fixes required validation for boolean custom fields (checkbox/toggle) by switching from required to accepted while preserving required UI indicators.

Changes:

  • Introduce custom-fields.fields.description_max_length config (default 255) and apply it to field/section description inputs.
  • Fix required boolean validation by using Laravel’s accepted rule (and avoiding the ineffective required rule for false).
  • Add feature tests covering required checkbox/toggle behavior.

Reviewed changes

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

Show a summary per file
File Description
config/custom-fields.php Adds fields.description_max_length config key.
src/Filament/Management/Schemas/FieldForm.php Uses config-driven max length for field description textarea.
src/Filament/Management/Schemas/SectionForm.php Uses config-driven max length for section description textarea.
src/Filament/Integration/Base/AbstractFormComponent.php Uses markAsRequired() for required boolean fields instead of required().
src/Services/ValidationService.php Adds accepted rule for required boolean fields.
tests/Feature/Integration/ValidationCapabilitiesTest.php Adds tests for required boolean validation.

Comment thread src/Filament/Management/Schemas/SectionForm.php Outdated
Comment thread config/custom-fields.php
Section descriptions use a VARCHAR(255) column, so sharing the same
config key with field descriptions (stored in JSON) could cause DB
errors if increased beyond 255. Separate keys make the constraint
explicit.
Sections aren't fields, so section config shouldn't live under the
fields key. Follows the existing pattern of top-level keys for
separate concerns (management, currency, database).
@ManukMinasyan ManukMinasyan merged commit 21faf53 into 3.x Apr 15, 2026
3 checks passed
@ManukMinasyan ManukMinasyan deleted the feat/configurable-description-maxlength-boolean-required-fix branch April 15, 2026 17:38
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.

2 participants