refactor #toData and #loadData to work with generic form-like data