generated from filamentphp/plugin-skeleton
-
-
Notifications
You must be signed in to change notification settings - Fork 2
Fix: Add validation for duplicate tags when creating new tags #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Add validation rule to TextInput in createOptionForm to check for duplicate tag slugs - Validation error now displays inline on the form field - Prevents SQL errors when attempting to create duplicate tags - Applied to EditFile, EditLink, and EditFolder pages
- Add duplicate tag check in createOptionUsing callback - This ensures validation runs even if form validation doesn't trigger - Prevents SQL errors when creating duplicate tags
- Use Validator::make()->validate() instead of throwing ValidationException directly - Add validationAttribute for better error messages - Add empty value check in validation rule - This should ensure Filament properly displays validation errors in the modal
- Add live(onBlur: true) to trigger validation when user leaves the field - This ensures validation errors are displayed in real-time - Validation will show immediately when a duplicate tag name is detected
- Create UniqueTagName Rule class that implements ValidationRule interface - Replace closure-based rules with Rule class instance - Rule classes are more reliable in Filament modal forms - This ensures validation executes properly in createOptionForm context
- Form validation with UniqueTagName Rule should prevent duplicates - createOptionUsing should only be called if validation passes - Simplifies code by removing redundant validation check
- This parameter is not recognized by PHPStan - Causes CI build failures - Removing it to fix PHPStan configuration error
- Generate baseline from actual errors (162 errors) - Remove ignoreErrors section from phpstan.neon.dist - Fix duplicate Asset import in FilamentLibraryServiceProvider - Baseline approach is more maintainable and tracks specific errors
- Add env() error from config file - Add missing errors reported by CI - Remove/update mismatched baseline patterns - Fix error counts to match actual occurrences
- Remove env() error pattern (not occurring) - Fix LibraryItem type error pattern to match actual error - Remove non-matching patterns for role, user, getEffectiveAccessControl - PHPStan now passes with zero errors
swilla
approved these changes
Dec 2, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
When creating a new tag in the library item edit forms, attempting to create a tag with a name that already exists (or a name that would result in the same slug) causes a SQL error due to the unique constraint on the slug column.
Solution
Added validation rule to the TextInput in the createOptionForm to check for duplicate tag slugs before form submission. The validation error now displays inline on the form field, providing better UX.
Changes
Testing