How to extend Form submit button?

Showing results for 
Search instead for 
Did you mean: 

How to extend Form submit button?

I have the follow code which creates a button that will display a dialog to create a node. I want to extend the logic before submitting and after submitting.

Before submitting: I want to check some existing nodes' properties if there are any duplicates. Prevent creation of the new node if there are duplicates.

After submitting: I want to fire an Aikau topic to refresh a certain widget or refresh the page.

I'm not sure where to start to extend the submit function. I've checked the FormProcessor but i'm not sure if that's the right place.

function getListCreateButton() {
return {
name: "alfresco/buttons/AlfButton",
config: {
style: {
marginTop: "5px",
marginBottom: "5px"
label: "test",
additionalCssClasses: "call-to-action",
publishTopic: "ALF_FORM_REQUEST",
publishPayload: {
formConfig: {
useDialog: true,
dialogTitle: "test"
alfDestination: getListDestination(),
itemId: "rlarchive:aListItem",
itemKind: "type",
mode: "create"