The rails form_tag defaults to UTF-8. I would like to change the form to accept ISO-8859-1. From what I've read it seems like the following should work:
<%= form_tag subscribe_checkout_path, :id => 'checkoutForm' , :'accept-charset' => 'ISO-8859-1' do %>
<% end %>
It is not changing the accept-charset. Is this a problem with rails or am I doing something wrong?
This is bug in Rails. It has hardcoded UTF-8 value for it attribute.
So, I recommend to post issue or PR for fix this problem to Rails. Seems like it will be trivial fix.
You can monkey-patch the html_options_for_form
by modifying the app/helpers/application_helper.rb
like this:
module ApplicationHelper
private def html_options_for_form(url_for_options, options)
html_options = super(url_for_options, options)
html_options["accept-charset"] = "ISO-8859-1"
html_options
end
def utf8_enforcer_tag
"".html_safe
end
end
I also override the utf8_enforcer_tag
that returns <input name="utf8" type="hidden" value="✓" />
originally.