Move database query from group form view to controller.