skinny-azureS
Refine3y ago
4 replies
skinny-azure

Change values before sending to server

Hello,
I was wondering if it was possible to change the values of formProps?.data?.data before sending them to the server (i.e. I want to add/remove/modify information when I click on the save button) to send them correctly to the server.
export default function SessionsEdit(): ReactElement | null {

    // Variables

    const { id } = useParams();

    // Initiate the form
    const {formProps, saveButtonProps, formLoading: loadingForm, queryResult: dataSession } = useForm<ISession>({
        dataProviderName: PROVIDERS.LEARNING_LAB,
        resource: "session",
        id: id,

    });

    // Initiate the select with clients
    const { data: queryClients, isLoading: loadingClients } = useList<IClient>({
        dataProviderName: PROVIDERS.LEARNING_LAB,
        resource: "clients",
    })

    // Initiate the select with clients
    const { data: queryAuthentications, isLoading: loadingAuths } = useList<IAuthentication>({
        dataProviderName: PROVIDERS.LEARNING_LAB,
        resource: "authentications",
    })

    const clients: IClient[] = queryClients?.data ?? []
    const authentications: IAuthentication[] = queryAuthentications?.data ?? []

    // Functions

return (
        <Edit isLoading={loadingForm} saveButtonProps={saveButtonProps}>
            <Form layout="vertical" {...formProps}>
                <GenerateFormItem label="Titre" name="title" icon="ant-design:notification-outlined">
                    <Input/>
                </GenerateFormItem>
            </Form>
        </Edit>
    )
}
Was this page helpful?