Skip to content

Commit

Permalink
activate error locale
Browse files Browse the repository at this point in the history
  • Loading branch information
bastihilger committed Jul 10, 2023
1 parent 014e8a9 commit 0256a2a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion dist/js/translatable-field.js

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions resources/js/components/FormField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,20 @@ export default {
components: { LocaleTabs },
mixins: [HandlesValidationErrors, FormField, TranslatableField],
props: ['field', 'resourceId', 'resourceName'],
watch: {
errors(newErrors, oldErrors) {
let localeIsSet = false;
_.each(newErrors, (error) => {
_.each(error, (messages, key) => {
if (!localeIsSet && _.startsWith(key, this.field.attribute+'.')) {
this.activeLocale = key.substring(key.indexOf('.')+1);
localeIsSet = true;
}
});
});
}
},
methods: {
setInitialValue() {
// Do nothing
Expand Down
2 changes: 2 additions & 0 deletions resources/js/mixins/TranslatableField.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export default {

// Listen to setAllLocale event
Nova.$on('nova-translatable@setAllLocale', this.setActiveLocale);


},

mounted() {
Expand Down

0 comments on commit 0256a2a

Please sign in to comment.