Comments (2)
Hello,
I had to refresh my memory for a second, but there is a problem when using nested attribute syntax like post.slug
.
You can also use this syntax to submit multiple translations, like slug.en
.
So in your case that would becomepost.slug.en
, etc.
I have to detect the locale in the validation rule. The way I do this by getting any string after a dot.
Because a locale can be anything, there is no way to distinguish it from a field name.
If you just submit a slug
attribute, then there is no dot in the attribute name and the app's locale is used.
laravel-unique-translation/src/UniqueTranslationValidator.php
Lines 126 to 131 in a26017d
I don't know if there is any other way to handle this that supports nested arrays...
Edit:
One workaround that should work is be to add the locale to the form field: name="post[slug][en]"
Then validate post.slug.*
from laravel-unique-translation.
Hello @ivanvermeyen,
Your explanation is very clear, I understood the problem and if I use post.slug.*
it works fine! It's an architecture issue on my side: currently, my requests validate the slug for the current language of the user with app()->getLocale()
. However, there will be only one form per resource in the back-office, so I actually have to support the validation of several slugs at the same time (the entities are shared between the different languages, only some fields like the title and the slug are translatable).
Thanks for your help, I'll do the corrections on my side 👍 By the way I'll also implement your laravel-localized-routes package for the front-office, it looks great 😎
from laravel-unique-translation.
Related Issues (20)
- unique validation error while updating using form request HOT 4
- JSON_EXTRACT() function not exist issue with MySQL lower versions (to 5.6) HOT 5
- Unique validation with ar. HOT 17
- ErrorException
- an issue with spatie/laravel-tags HOT 2
- not working with arabic language HOT 5
- MariaDB / PostgreSQL compatibility HOT 1
- Error during test Undefined array key "collation" HOT 6
- Does not work for PostgreSQL v15 HOT 6
- Filament support HOT 6
- ErrorException: Array to string conversion HOT 2
- Is compatible with Astrotomic/laravel-translatable? HOT 1
- getFilamentAttributeNameAndLocale Returns an array incorrectly HOT 1
- Ignore deleted_at soft deteled field HOT 6
- Too many messages HOT 5
- Support for laravel 6.x HOT 1
- Support spatie/nova-translatable HOT 11
- Unique comparison is case sensitive HOT 3
- How to validate a single value? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-unique-translation.