Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing fields_for helper, and some forms weirdness #21

Closed
leafo opened this issue Feb 4, 2015 · 4 comments
Closed

Missing fields_for helper, and some forms weirdness #21

leafo opened this issue Feb 4, 2015 · 4 comments

Comments

@leafo
Copy link
Contributor

leafo commented Feb 4, 2015

It should be possible to do

form_for :test_form do |f|
  f.text_field "hello"
  f.fields_for :inner_thing do |inner|
    inner.text_field "greets"
  end
end

But fields_for is not a helper defined on form_for helper.

I added fields_for to the output_yielded_methods, which fixed it for my example above, generting the correct HTML:

<form accept-charset="UTF-8" action="/test_form" method="post"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="&#x2713;" /><input name="authenticity_token" type="hidden" value="j4Dax68aX/t7ajwBlpTTjeMT5MAaZjrNVYfE/yTW9ts=" /></div><input id="test_form_hello" name="test_form[hello]" size="30" type="text" /><input id="test_form_inner_thing_greets" name="test_form[inner_thing][greets]" size="30" type="text" /></form>

But, if I add an additional tag within the fields_for block, inner.text_field "greets" is no longer output.

form_for :test_form do |f|
  f.text_field "hello"
  f.fields_for :inner_thing do |inner|
    inner.text_field "greets"
    div "hello"
  end
end

Outputs the HTML, (notice the div tag is there, but not the input)

<form accept-charset="UTF-8" action="/test_form" method="post"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="&#x2713;" /><input name="authenticity_token" type="hidden" value="j4Dax68aX/t7ajwBlpTTjeMT5MAaZjrNVYfE/yTW9ts=" /></div><input id="test_form_hello" name="test_form[hello]" size="30" type="text" /><div>hello</div></form>
@ageweke
Copy link
Owner

ageweke commented Feb 5, 2015

What a seriously weird bug (i.e., adding another tag in the inner block makes the text field disappear).

I’ve written a spec that reproduces the issue, exactly as you said…working on fixing it now.

@ageweke
Copy link
Owner

ageweke commented Feb 9, 2015

OK, I understand exactly what's going on here, and how to fix it. I think I need to reify some of the helper definition logic in lib/fortitude/widget/helpers.rb. Proceeding…

ageweke added a commit that referenced this issue Feb 10, 2015
ageweke added a commit that referenced this issue Feb 10, 2015
@ageweke
Copy link
Owner

ageweke commented Feb 10, 2015

Just pushed the fix. Once it passes Travis, I'll release 0.9.4.

@ageweke
Copy link
Owner

ageweke commented Feb 11, 2015

Just released 0.9.4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants