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)
|
|
}
|
|
|
|
|
|
}
|
|
|