space10-community / conversational-form

Turning web forms into conversations
https://space10-community.github.io/conversational-form/
MIT License
3.8k stars 778 forks source link

Is it possible to pass an argument to submitCallback? #460

Open diego-v opened 2 years ago

diego-v commented 2 years ago

In have this code

        cf = ConversationalForm.startTheConversation({
            options: {
                theme: 'green',
                submitCallback: submitCallback,
                preventAutoFocus: true,
            },
            tags: tags,
        });
        ref.current.appendChild(cf.el);
        return function unMount() {
            cf.remove();
        };
    }, []);

I would like to pass an argument to submitCallback in order to use it in the function:

function submitCallback(uniqueId) {
        var formData = cf.getFormData(true);
        cf.addRobotChatResponse("Listo!")
        actions.updateCompanyAction({
            id: uniqueId,
            name: formData.name,
            country: formData.country,
            sites: formData.sites
        });
    }

Is that possible?

Thanks!

Great library by the way...!