Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Hidden Fields #119

jduarte opened this Issue · 12 comments

4 participants

José Duarte Jonas Grimfelt Justin French Patrik Affentranger
José Duarte

It's impossible to pass a value to a hidden field even if we specify something like:

<%= f.input :object_id, :as => :hidden, :input_html => {:value =>} %>

By the way,

Great work on the plugin! It's becoming really useful!

Jonas Grimfelt

This works:

<%= f.input :object_id, :as => :hidden, :value => %>

...but I can agree that this is a bit inconsistent. What do you think Justin?

Jonas Grimfelt


I think this should be possible to set the value using html_options. My argument is that it's confusing that only hidden_input lacks the html_options hash just because it's not a visible input.

Justin French

So you've made the API the same as, say, string input?

Jonas Grimfelt

Uhm, not sure what you mean, but see the spec. The only input_html-option that works is :value - so that people don't get stuck like jduarte did above. This might need a bit more reflection maybe, but I just pushed this so we got something physical (digital). =)

Jonas Grimfelt

jduarte said:

It's a little bit off-topic but since we're talking of hidden inputs.
For me it doesn't make sense an hidden input being wrapped in a li tag by default.
I think it can mess up uneccessarely with the CSS.
What do you think?

Jonas Grimfelt

Yes, maybe hidden fields should be placed in a hidden div in the form header just like Rails does this. Should be straight-forward to do with the content_for helper. Makes sense to me.

Justin French

Hidden fields cannot be rendered without the LI wrapper because it's invalid to have child elements of an OL or UL that are not an LI, which is why we render them within an LI, and why the default stylesheets supplied with formtastic hide li.hidden inputs. Closing.

Jonas Grimfelt

But did you reflect on my last suggestion? Se how the security token gets attached to a Rails form. My suggestion would be to stack them all like that.

Justin French

Ah, I missed the content_for bit of your message. Absolutely, feel free to have a play!

Patrik Affentranger
pzi commented

Hello! Has there ever been a solution for this? I'd prefer not having "empty" lis in my source... This also messes with screenreaders.

Justin French

@pzi on which bit of this thread? Moving the hidden inputs of the list to avoid empty LIs? No progress AFAIK. Feel free to explore this in a PR (preferred) or raise a new issue, there's a high chance that I'd merge this if it were solved, but a low chance that I'll be motivated to do the work myself in the near term :)

Patrik Affentranger
pzi commented

Yeah, the bit that adds the hidden fields into div of the form, like rails does, as suggested by @grimen.

Unfortunately, I am no Ruby developer. So chances that I can do it myself are very slim. I can raise a new issue for sure though... :)

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.