Change field before send to api
Here is my code
Here is my code for my create page, but i want, before sending data to the server, updating the key "clients", i want to change clients which is a string list to a list object like this clients: [{id: string}, ........] where id is the current string
export default function SessionsEdit(): ReactElement | null {
// Variables
const { formProps, saveButtonProps } = useForm<ISession>({
dataProviderName: PROVIDERS.LEARNING_LAB,
resource: "session",
});
const { data: dataClients } = useList<IClient>({
dataProviderName: PROVIDERS.LEARNING_LAB,
resource: "clients",
});
const clients: IClient[] = dataClients?.data ?? []
return (
<Create saveButtonProps={saveButtonProps}>
<Form layout="vertical" {...formProps}>
<GenerateFormItem label="Clients" name="clients" icon="ant-design:login-outlined" component={
<Select
mode="tags"
allowClear
options={clients.map(client => ({label: client.name, value: client.id}))}
onChange={(value) => {
console.log(value);
}}
/>
}/>
</Form>
</Create>
)
}export default function SessionsEdit(): ReactElement | null {
// Variables
const { formProps, saveButtonProps } = useForm<ISession>({
dataProviderName: PROVIDERS.LEARNING_LAB,
resource: "session",
});
const { data: dataClients } = useList<IClient>({
dataProviderName: PROVIDERS.LEARNING_LAB,
resource: "clients",
});
const clients: IClient[] = dataClients?.data ?? []
return (
<Create saveButtonProps={saveButtonProps}>
<Form layout="vertical" {...formProps}>
<GenerateFormItem label="Clients" name="clients" icon="ant-design:login-outlined" component={
<Select
mode="tags"
allowClear
options={clients.map(client => ({label: client.name, value: client.id}))}
onChange={(value) => {
console.log(value);
}}
/>
}/>
</Form>
</Create>
)
}Here is my code for my create page, but i want, before sending data to the server, updating the key "clients", i want to change clients which is a string list to a list object like this clients: [{id: string}, ........] where id is the current string
