react-form-builder
react-form-builder copied to clipboard
Access data in Custom buttons/events
I have shown 3 buttons inside submitButton container. Below is the code for the same:
<ReactFormGenerator
key={uuidv4()}
action_name={t('action.save')}
onSubmit={onSubmit}
data={data || []}
answer_data={getAnswers()}
submitButton={
<div>
<Button
type="primary"
htmlType="submit"
>
Update
</Button>
<ColorButton
style={{ marginLeft: 10, marginRight: 10 }}
type="primary"
override="colorSuccess"
onClick={() => onClick('approve')}
>
Approve
</ColorButton>
<ColorButton
type="primary"
override="colorError"
onClick={() => onClick('reject')}
>
Reject
</ColorButton>
</div>
}
/>
On click of Approve/Reject button I want to pass "data" as well. How can I access form data? I tried to override onChange event and update state of the answers but then after each keystroke the input component loses focus and I need to click again in order to type the next character.