Fix generated FQDN not being submitted #249

Merged
tobru merged 1 commit from 241-fqdn-saving into main 2025-10-24 13:55:13 +00:00
2 changed files with 11 additions and 1 deletions

View file

@ -129,6 +129,8 @@ const updateRemoveButtonVisibility = (container) => {
})
}
window.updateHiddenInput = updateHiddenInput
document.addEventListener('DOMContentLoaded', initDynamicArrayWidget)
document.addEventListener('htmx:afterSwap', initDynamicArrayWidget)
document.addEventListener('htmx:afterSettle', initDynamicArrayWidget)

View file

@ -1,6 +1,6 @@
const initializeFqdnGeneration = () => {
const nameField = document.querySelector('input[name="name"]');
const nameField = document.querySelector('input#id_name');
const fqdnField = document.querySelector('label[for="id_spec.parameters.service.fqdn"] + div input.array-item-input');
if (nameField && fqdnField) {
@ -17,6 +17,10 @@ const initializeFqdnGeneration = () => {
newNameField.addEventListener('input', function() {
if (!newFqdnField.dataset.manuallyEdited) {
newFqdnField.value = generateFqdn(this.value);
const container = newFqdnField.closest('.dynamic-array-widget');
if (container && window.updateHiddenInput) {
window.updateHiddenInput(container);
}
}
});
@ -26,6 +30,10 @@ const initializeFqdnGeneration = () => {
if (newNameField.value && !newFqdnField.value) {
newFqdnField.value = generateFqdn(newNameField.value);
const container = newFqdnField.closest('.dynamic-array-widget');
if (container && window.updateHiddenInput) {
window.updateHiddenInput(container);
}
}
}
}