react-form-builder icon indicating copy to clipboard operation
react-form-builder copied to clipboard

Access data in Custom buttons/events

Open ritesh-nahar opened this issue 1 year ago • 0 comments

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.

Screenshot 2024-01-22 at 01 04 46

ritesh-nahar avatar Jan 22 '24 00:01 ritesh-nahar