Move form functions into form controller