Getting "Serialization of 'Closure' is not allowed" error when submitting the form