refactored createForm into separate functions to handle array ref and object ref