0

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 %>

1 Answer 1

1

For text_field write just

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

Without input_html

Sign up to request clarification or add additional context in comments.

1 Comment

Beautiful, it worked, Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.