# Hidden fields on complex forms

**URL:** <https://www.ruby-forum.com/t/hidden-fields-on-complex-forms/144993>\
**Category:** Rails\
**Created:** [August 5, 2008, 12:47am UTC](https://www.ruby-forum.com/t/hidden-fields-on-complex-forms/144993 "2008-08-05T00:47:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sheepfunk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f1d935/32.png) [@sheepfunk](https://www.ruby-forum.com/u/sheepfunk)\
**Post date:** [August 5, 2008, 12:47am UTC](https://www.ruby-forum.com/t/hidden-fields-on-complex-forms/144993/1 "2008-08-05T00:47:47Z")

</div>

I’m trying to pass the id of an object in a hidden field in a complex  
form and I while I’ve googled a bunch on this I can’t seem to figure out  
the problem

My form looks like this:

\<% fields\_for “recipe[ingredient\_attributes][]”, ingredient do |  
ingredient\_form |%\>

\<% if ingredient.new\_record? %\> \<%= link\_to\_function 'remove', "this.up('.ingredient').remove()" %\> \<% else %\>

```
  <!-- this is the field that keeps failing -->

  <%= ingredient_form.hidden_field :id %>

  <!-- everything works fine if this is a text_field -->

  <%= link_to_function 'remove', "mark_for_destroy(this,

```

‘ingredient’)" %\>  
  
  
\<% end %\>

 \<% end %\>

and I keep getting this error:

wrong number of arguments (3 for 2)

how is:

\<%= ingredient\_form.hidden\_field :id %\>

three arguments?

If I remove the :id it says I have no arguments, and as far as I can  
tell there’s nothing special in :id. I get the same error if I use a  
param name that isn’t used anywhere else in my code.

---

<div class="post-metadata">

**Author:** ![sheepfunk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f1d935/32.png) [@sheepfunk](https://www.ruby-forum.com/u/sheepfunk)\
**Post date:** [August 5, 2008, 1:02am UTC](https://www.ruby-forum.com/t/hidden-fields-on-complex-forms/144993/2 "2008-08-05T01:02:20Z")

</div>

On Aug 4, 11:47 pm, Skye Weir-Mathews \<rails-mailing-l…@andreas-  
[s.net](http://s.net)\> wrote:

> how is:
> 
> \<%= ingredient\_form.hidden\_field :id %\>
> 
> three arguments?

Because that function is calling some other function and it’s that  
function that is calling some function with the wrong number of  
arguments (look at the stack trace).  
Typically this is because some plugin is overriding an internal rails  
function and the signature of that function has changed since the  
plugin was written.

Fred
