Skip to content

Commit

Permalink
fix(dynamic-forms.js): Don't remove name attribute from form inputs a…
Browse files Browse the repository at this point in the history
…fter processing (#14244)

* fix(dynamic-forms.js): Don't remove name attriubute from form inputs after processing

* fix(/landscape/pricing#get-in-touch): Use appropriate js CSS references

* chore(intl-tel-input): Update flag assets & bump version to 24.3.5
  • Loading branch information
petesfrench authored Aug 30, 2024
1 parent a007905 commit cebc1b4
Show file tree
Hide file tree
Showing 9 changed files with 867 additions and 604 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
"flickity": "^3.0.0",
"formik": "2.4.6",
"globals": "^15.8.0",
"intl-tel-input": "24.3.4",
"intl-tel-input": "24.3.5",
"postcss": "8.4.40",
"postcss-cli": "11.0.0",
"prop-types": "15.8.1",
Expand Down
75 changes: 8 additions & 67 deletions static/js/src/dynamic-forms.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,23 +246,13 @@ import { prepareInputFields } from "./prepare-form-inputs.js";
path: window.location.pathname,
});
} else {
var valid = true;

if (button.classList.contains("js-validate-form")) {
var form = button.closest("form");

valid = validateForm(form);
}

if (valid) {
index = index + 1;
setState(index);
dataLayer.push({
event: "interactive-forms",
action: "goto:" + index,
path: window.location.pathname,
});
}
index = index + 1;
setState(index);
dataLayer.push({
event: "interactive-forms",
action: "goto:" + index,
path: window.location.pathname,
});
}
});
});
Expand All @@ -283,49 +273,6 @@ import { prepareInputFields } from "./prepare-form-inputs.js";
});
});

// Checks additional required fields to see whether a value has been set
function validateForm(form) {
var fields = form.querySelectorAll("[required]");
var validStates = [];

fields.forEach((field) => {
var fieldName = field.getAttribute("name");
var inputs = form.querySelectorAll(`[name="${fieldName}"]`);
var validationMessage = document.querySelector(
`.js-validation-${fieldName}`,
);
var inputValid = false;

inputs.forEach((input) => {
if (input.type === "checkbox" && input.checked) {
inputValid = true;
}

if (input.type === "radio" && input.checked) {
inputValid = true;
}

if (input.type === "text" && input.value) {
inputValid = true;
}

if (input.type === "textarea" && input.value) {
inputValid = true;
}
});

if (!inputValid) {
validationMessage.classList.remove("u-hide");
} else {
validationMessage.classList.add("u-hide");
}

validStates.push(inputValid);
});

return !validStates.includes(false);
}

// Updates the index and renders the changes
function setState(index) {
contactIndex = index;
Expand Down Expand Up @@ -385,8 +332,8 @@ import { prepareInputFields } from "./prepare-form-inputs.js";
message += fieldTitle.innerText + "\r\n";
}

// Loop through each input and add to Comments_from_lead__c
inputs.forEach(function (input) {
var removeInputName = true;
switch (input.type) {
case "radio":
if (input.checked) {
Expand All @@ -398,8 +345,6 @@ import { prepareInputFields } from "./prepare-form-inputs.js";
if (fieldsetForm) {
message += input.value + comma + " ";
} else {
// Forms that have column separation
removeInputName = false;
var subSectionText = "";
if (
input.closest('[class*="col-"]') &&
Expand Down Expand Up @@ -434,10 +379,6 @@ import { prepareInputFields } from "./prepare-form-inputs.js";
}
break;
}
// Remove name attribute to submit to Marketo
if (submit && removeInputName) {
input.removeAttribute("name");
}
});
message += "\r\n\r\n";
});
Expand Down
4 changes: 2 additions & 2 deletions static/sass/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,12 @@ $color-shadow: rgba(0, 0, 0, 0.5) !default;

// Overide the path to flags for dial codes
.iti__flag {
background-image: url("#{$assets-path}b451b4db-flags.png");
background-image: url("#{$assets-path}685bc1a3-flags.png");
}

@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
.iti__flag {
background-image: url("#{$assets-path}5bb5145d[email protected]");
background-image: url("#{$assets-path}01807c27[email protected]");
}
}

Expand Down
432 changes: 346 additions & 86 deletions templates/shared/forms/interactive/hpc.html

Large diffs are not rendered by default.

Loading

0 comments on commit cebc1b4

Please sign in to comment.