React form hook using button as input

Viewed 18

I am trying to use react form hook in my react form. and there i needed to use a field call 'status' which will have 0 or 1 value ie accept or reject. and as input i want to have two submit button with Accept And Reject.

I tried following but didnt worked

//this is schema
const schema = yup.object({
    reply: yup.string().required("Reply"),
    status: yup.number().oneOf([1, 2]),
});
          // this is form controller        
                                 <Controller
                                        name="status"
                                        control={control}
                                        render={({ field, fieldState }) => (
                                            <Box display={'flex'} gap={2}>
                                                <Button
                                                    color="error"
                                                    type="submit"
                                                    value={1}
                                                    variant='contained'
                                                    {...field}
                                                >Accept</Button>
                                                <Button
                                                    color="warning"
                                                    type="submit"
                                                    variant='contained'
                                                    value={2}
                                                    {...field}
                                                >Reject</Button>
                                            </Box>
                                        )}
                                    />
0 Answers
Related