bootstrap-ruby / bootstrap_form

Official repository of the bootstrap_form gem, a Rails form builder that makes it super easy to create beautiful-looking forms using Bootstrap 5.
MIT License
1.64k stars 352 forks source link

render problem #724

Open Yasingthb opened 4 months ago

Yasingthb commented 4 months ago

The following code snippet provided in the documentation is not functioning as expected when used with Phlex framework:

f.email_field(:email, append: link_to("Go", "#", class: "btn btn-secondary")) Instead of rendering the button correctly, it appears as a separate input element in the top right corner. However, when I use capture, it works correctly. Is this a known issue?

If I use capture it gives the result like this (f.email_field(:email, append: capture { link_to("Go", "#", class: "btn btn-secondary")}))

image

dont use capture (f.email_field(:email, append: link_to("Go", "#", class: "btn btn-secondary")))

image
av-martin commented 4 months ago

@Yasingthb it appears that Phlex immediately renders the html to the current context, where rails methods normally returns a string instead. So link_to(*args) in Phlex is equivalent to concat(link_to(*args)) in rails.

Yasingthb commented 4 months ago

Thank you

lcreid commented 4 months ago

Thanks for responding, @av-martin . @Yasingthb does this resolve your issue? It seems Phlex works in a way that isn't really compatible with how Rails and bootstrap_form work.