# \[rails3.0.0.beta4\] extend form\_tag to always include a hidden field

**URL:** <https://www.ruby-forum.com/t/rails3-0-0-beta4-extend-form-tag-to-always-include-a-hidden-field/193224>\
**Category:** Rails\
**Created:** [August 13, 2010, 3:03pm UTC](https://www.ruby-forum.com/t/rails3-0-0-beta4-extend-form-tag-to-always-include-a-hidden-field/193224 "2010-08-13T15:03:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![joahking](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/90db22/32.png) [@joahking](https://www.ruby-forum.com/u/joahking)\
**Post date:** [August 13, 2010, 3:03pm UTC](https://www.ruby-forum.com/t/rails3-0-0-beta4-extend-form-tag-to-always-include-a-hidden-field/193224/1 "2010-08-13T15:03:52Z")

</div>

hi there,  
I want every form in the site to add a hidden\_field, basically I want  
them  
to always submit the I18n.locale, I’ve tried to alias form\_tag\_html  
method  
of ActionView::Helpers::FormTagHelper like this:

# in #{MY\_APP\_ROOT}/lib/action\_view/helpers/form\_tag\_helper.rb

module ActionView::Helpers::FormTagHelper

def form\_tag\_html\_with\_locale(html\_options)  
form = form\_tag\_html\_without\_locale(html\_options)  
form.safe\_contact(hidden\_field\_tag(‘locale’, I18n.locale))  
end  
alias\_method\_chain :form\_tag\_html, :locale

end

but I get this exception:

in `alias_method': undefined method `form\_tag\_html’ for module  
`ActionView::Helpers::FormTagHelper’ (NameError)

am I missing something, is this a good approach for this? (I mean  
since form\_tag\_html is a private method, for instance)

what’s your opinion? any ideas? TIA  
joaquin

–

> **[Least Significant Bit](http://www.least-significant-bit.com)**
>
> The blog of Joaquin Rivera Padron (@joahking). Here I share my thoughts about programming, architecture, scalability, Open Source, Ruby, Testing, BDD, linux and more.
