Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Rails Form input_html not working for calling javascipt controller

So I have this input field, using form Rails 7.0.2.3, and I’m looking forward to call a controller but this is not connecting.

<%= form_with url: "/projects/#{@project.id}", method: :get do |form| %>
   <%= form.text_field :query, html5: true, input_html: { data: { controller: "flatpickr" } } %>
   <%= form.submit '🔎', class: 'button' %>
<% end %>

If I put in the next way, it works, but I need it to be in the input field.
I’m guessing the problem is with input_html tag

<%= form_with url: "/projects/#{@project.id}", method: :get do |form| %>
   <div data-controller="flatpickr">
     <%= form.text_field :query %>
   </div>
   <%= form.submit '🔎', class: 'button' %>
<% end %>

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

For text_field write just

<%= form.text_field :query, html5: true, data: { controller: "flatpickr" } %>

Without input_html

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading