是否可以将隐藏字段添加到所有表单标签?我正在尝试通过以下方式进行操作:
module ActionView::Helpers::FormTagHelper
def form_tag(url_for_options = {}, options = {}, &block)
html_options = html_options_for_form(url_for_options, options)
if block_given?
f = form_tag_in_block(html_options, &block)
else
f = form_tag_html(html_options)
end
hidden_f = ActiveSupport::SafeBuffer.new "<input name='n' type='hidden' value='v' /><\/form>"
f.gsub!(/<\/form>/, hidden_f)
f
end
end
但是服务器显示错误:
ActionView::Template::Error (Could not concatenate to the buffer because it is not html safe.):
我该怎么做?