Phoenix form empty value as nil

Can I set default behavior for empty fields in a Phoenix form to become nil values in changeset (then in database ) instead of “”?

In your controller action you can pattern match, either the function arguments (and create two functions cláusulas) or with a case, i.e (for a createaction):

def create(conn, %{"your_form_key" => your_form_params}) do
    your_form_params = 
      case your_form_params do
        %{"key" => upload} ->        #the format you expect
            # your code here when not empty                                                                                           
          _ ->
            Map.put(your_form_params, "key", nil)

@pedromvieira This sounds like you are looking for scrub_parameters/2 :