Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

boolean hidden field ignores input_html when :nested #619

Closed
amiel opened this Issue · 5 comments

2 participants

@amiel

At first glance it would make sense that the hidden boolean field would ignore input_html options. However, when input_html includes customization of the name attribute, this produces unexpected results.

Example:

  f.input :tos, as: :boolean, label: "I agree to the Terms of Service", input_html: { name: 'tos' }

renders:

<div class="form-field boolean optional">
  <input name="identity[tos]" type="hidden" value="0" />
  <label class="boolean optional control-label checkbox" for="identity_tos">
    <input class="boolean optional" id="identity_tos" name="tos" type="checkbox" value="1" />
    I agree to the Terms of Service
  </label>
</div>

Note that the name attribute of both <input> tags.

The expected behavior is that the hidden field has name="tos" as opposed to name="identity[tos]".

@amiel amiel referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@amiel

By the way, this bug is specific to when :boolean_type => :nested.

A temporary workaround is to set :boolean_type => :inline.

@amiel

Oh, also, sorry I forgot to mention. I'd be happy to work on this, but I'm not sure what the best direction to go is. So I figured I would see if a conversation started first, or if there are any thoughts on implementation.

At first glance, it seems like the easiest thing would be to allow BooleanInput#build_check_box to create the hidden field even if it is nested. But it looks like great effort has been made to split the hidden field and the checkbox in te nested case.

Looking for input...

@amiel
@amiel

Closed in favor of pull-request #620

@amiel amiel closed this
@amiel amiel referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
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.