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
How can I mark a field, using useForm in conjunction with defineField as required without using a typedSchema in validationSchema depending on an other field value?
Simple example:
const{ values, defineField }=useForm({initialValues: {markAsRequired: false,name: ''},validationSchema: {name: [<arrayoffunctionsforvalidations>]
}})const[name,nameAttr]=defineField('name',{props(state){state.required// <---- how can I set this to true when 'markedAsRequired' is set to true?// I could of cause directly access values.markedAsrequired...return{required: values.markedAsrequired//... but somethimes the condition is not that simple}}})
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
How can I mark a field, using
useForm
in conjunction withdefineField
as required without using a typedSchema in validationSchema depending on an other field value?Simple example:
Beta Was this translation helpful? Give feedback.
All reactions