refactoring code to remove if else statements

This is the refactoring that we talked about the other day.
Is there any reason to set the button's `formaction` instead of changing the form's `action`?