You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

26 lines
582 B

import { Controller } from "@hotwired/stimulus"
export default class extends Controller {
connect() {
this.input = document.createElement('input');
this.input.type = 'hidden';
this.input.name = '_locale'; // Set the name for the input
this.input.value = this.element.getAttribute('data-locale'); // Set the value for the input
this.element.appendChild(this.input);
}
setFormLocale(event) {
const locale = event.target.getAttribute('value')
this.input.value = locale
this.element.setAttribute('data-locale', locale)
}
}