mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Extract to a method that handle all the form elements
This commit is contained in:
committed by
Matt-Yorkley
parent
fbe69b8027
commit
f7662947dc
@@ -17,8 +17,11 @@ export default class extends Controller {
|
||||
});
|
||||
}
|
||||
|
||||
getFormElementsArray(container) {
|
||||
return Array.from(container.querySelectorAll("input, select, textarea"));
|
||||
}
|
||||
removeRequiredAttributeOnInput(container) {
|
||||
Array.from(container.getElementsByTagName("input")).forEach((i) => {
|
||||
this.getFormElementsArray(container).forEach((i) => {
|
||||
if (i.required) {
|
||||
i.dataset.required = i.required;
|
||||
i.required = false;
|
||||
@@ -27,7 +30,7 @@ export default class extends Controller {
|
||||
}
|
||||
|
||||
addRequiredAttributeOnInputIfNeeded(container) {
|
||||
Array.from(container.getElementsByTagName("input")).forEach((i) => {
|
||||
this.getFormElementsArray(container).forEach((i) => {
|
||||
if (i.dataset.required === "true") {
|
||||
i.required = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user