You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a custom form builder but since I want to be able to use the default one as well I created helper method for it:
# form_helper.rb
module FormHelper
def my_form_with(**args, &block)
form_with(builder: MyFormBuilder, **args, &block)
end
end
And when I try to use it inside any component I get two different results but neither of them is what I expect it to be. One renders the block twice - before and inside the form tag. The other one renders the block only before the form tag.
Note that when I use the form_with directly in the component's template it works so this has something to do with it being called from the helper.
Steps to reproduce
Create helper that receives &block, pass that block to any rails helper like form_with, link_to, etc. Use the created helper in the component.
Expected behavior
It should render the block inside the form tag and only once. The same way it works when used outside the component
Actual behavior
Example 1:
# component.html.erb
<%= helpers.my_form_with do %>
Example string
<% end>
Result:
Example string
<form action="..." method="post">
Example string
</form>
I believe that another PR aimed to resolve this issue was actually merged (#1307), and then subsequently reverted: #1432.
I've recently run into this issue, and I was wondering if there are any efforts being made to address it, now that we are no longer experimenting with a single output buffer.
I have a custom form builder but since I want to be able to use the default one as well I created helper method for it:
And when I try to use it inside any component I get two different results but neither of them is what I expect it to be. One renders the block twice - before and inside the
form
tag. The other one renders the block only before theform
tag.Note that when I use the
form_with
directly in the component's template it works so this has something to do with it being called from the helper.Steps to reproduce
Create helper that receives
&block
, pass that block to any rails helper likeform_with
,link_to
, etc. Use the created helper in the component.Expected behavior
It should render the block inside the
form
tag and only once. The same way it works when used outside the componentActual behavior
Example 1:
Result:
Example 2:
Result:
System configuration
Rails version: 6.1
Ruby version: 2.7.6
Gem version: 2.56.2
The text was updated successfully, but these errors were encountered: