diff --git a/src/front/Components/DesignSystem/Form/index.tsx b/src/front/Components/DesignSystem/Form/index.tsx index e66cd454..e37ada66 100644 --- a/src/front/Components/DesignSystem/Form/index.tsx +++ b/src/front/Components/DesignSystem/Form/index.tsx @@ -1,5 +1,6 @@ import React, { ReactNode } from "react"; -import BaseField, { IError, IProps as IBaseFieldProps } from "./Elements/BaseField"; + +import BaseField, { IProps as IBaseFieldProps, IError } from "./Elements/BaseField"; export type IBaseField = BaseField; @@ -90,13 +91,25 @@ export default class Form extends React.Component { if (this.props.onValidated) this.props.onValidated(); - const elementsValues = this.getAllChildrenFields(e).reduce( + const allChildren = this.getAllChildrenFields(e); + const elementsValues = allChildren.reduce( (obj, element) => ({ ...obj, [element.getAttribute("name") ?? ""]: (element as any).value }), {}, ); + const radioInputs = allChildren.filter((e) => e.getAttribute("type") === "radio").filter((e) => (e as any).checked); + const radioInputsValues = radioInputs.reduce( + (obj, element) => ({ ...obj, [element.getAttribute("name") ?? ""]: (element as any).value }), + {}, + ); + + const allInputs = { + ...elementsValues, + ...radioInputsValues, + } + if (this.props.onSubmit) { - this.props.onSubmit(e, elementsValues, this.onSubmitErrorApi); + this.props.onSubmit(e, allInputs, this.onSubmitErrorApi); } return { values: elementsValues };