Then you'll need to make CSS classes to manipulate that button element visibility. You can use msg.className
to add and remove CSS classes of dashoard widget.
[{"id":"335c379e74fcc961","type":"ui_form","z":"a248fb5a07a475d7","name":"","label":"","group":"da624dc283431947","order":0,"width":0,"height":0,"options":[{"label":"aa","value":"aa","type":"text","required":true,"rows":null},{"label":"bb","value":"bb","type":"text","required":false,"rows":null}],"formValue":{"aa":"","bb":""},"payload":"","submit":"submit","cancel":"cancel","topic":"topic","topicType":"msg","splitLayout":"","className":"","x":450,"y":230,"wires":[[]]},{"id":"f1a1ecefecdce7f4","type":"inject","z":"a248fb5a07a475d7","name":"show-cancel","props":[{"p":"className","v":"show-cancel","vt":"str"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":230,"y":190,"wires":[["335c379e74fcc961"]]},{"id":"ca61210d530f8543","type":"inject","z":"a248fb5a07a475d7","name":"hide cancel","props":[{"p":"className","v":"hide-cancel","vt":"str"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":230,"y":240,"wires":[["335c379e74fcc961"]]},{"id":"633e85819047b089","type":"ui_template","z":"a248fb5a07a475d7","group":"da624dc283431947","name":"CSS","order":1,"width":0,"height":0,"format":"<style>\n .hide-cancel button[type=\"button\"]{\n display:none;\n }\n .show-cancel button[type=\"button\"]{\n display:inline-block;\n }\n</style>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":true,"templateScope":"global","className":"","x":250,"y":130,"wires":[[]]},{"id":"da624dc283431947","type":"ui_group","name":"Default","tab":"a54106ae4134fcbf","order":1,"disp":true,"width":"6","collapse":false,"className":""},{"id":"a54106ae4134fcbf","type":"ui_tab","name":"Home","icon":"dashboard","disabled":false,"hidden":false}]