You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Some of our form components are sending their value when they are submitted inside a <form>. This shouldn't be happening since disabled fields must not be sent in a form POST request.
The affected components are:
Select
Radio Group
To Reproduce
Example:
Create a new React App using create-react-app.
Install the @dxc-technology\halstack-react dependencies and run the app.
Replace your App.jsx component code with:
const App = () => {
const handlerOnSubmit = (e) => {
// stop form submission for data validation
e.preventDefault();
const formData = new FormData(e.target);
const formProps = Object.fromEntries(formData);
console.log(formProps);
};
return (
<DxcInset space="2rem">
<DxcFlex direction="column" gap="2rem" wrap="wrap">
<form onSubmit={handlerOnSubmit} action="/user-data" method="post">
<DxcTextInput
label="Name"
name="name"
placeholder="Write your name"
defaultValue="Iván"
disabled
/>
<DxcCheckbox
label="Older than 16"
name="age"
defaultChecked
disabled
value="16"
/>
<DxcSwitch
label="Open to work"
name="openToWork"
value="opened"
defaultChecked
disabled
/>
<DxcRadioGroup
label="Gender"
name="gender"
options={RDoptions}
defaultValue="male"
disabled
/>
<DxcSlider
label="Select your height"
defaultValue={1.70}
step={0.01}
minValue={0}
maxValue={3}
showInput
name="height"
disabled
/>
<DxcSelect
name="city"
label="Select your favourite city"
placeholder="Choose a city"
defaultValue="madrid"
disabled
options={options}
/>
<DxcTextarea
label="Comments"
name="comments"
placeholder="Write your comments"
defaultValue="I like this form."
disabled
/>
<DxcButton type="submit" label="Submit" />
</form>
</DxcFlex>
</DxcInset>
);
};
This basically uses the FormData class to create the object which will be sent when submitting the form.
Open the Console of your browser.
See the log.
Expected behaviour
The console.log should print an empty object, which would then be sent in a POST request. Instead, both Select and Radio Group components are sending their respective values, although they are disabled.
Describe the bug
Some of our form components are sending their value when they are submitted inside a
<form>
. This shouldn't be happening since disabled fields must not be sent in a form POST request.The affected components are:
To Reproduce
Example:
create-react-app
.@dxc-technology\halstack-react
dependencies and run the app.This basically uses the
FormData
class to create the object which will be sent when submitting the form.Expected behaviour
The
console.log
should print an empty object, which would then be sent in a POST request. Instead, both Select and Radio Group components are sending their respective values, although they are disabled.Screenshots
Additional context
https://developer.mozilla.org/en-US/docs/Web/API/FormData/FormData
Disabled inputs are not submitted
The text was updated successfully, but these errors were encountered: