-1

I have a form_with like this:

= form_with model: product.product_posts.new do |f|
  = hidden_field_tag :container, '#related-products-list'
  = f.hidden_field :product_id
  = f.hidden_field :post_id, value: @post.id
  = f.submit "+", class: "btn btn-info m-btn m-btn--icon m-btn--icon-only m-btn--pill add-action-button"

How to get the same with a link_to to get full div clickable instead of the "+" button?

=link_to {SOLUTION} do
    .mydiv

1 Answers1

0

You can use Javascript to achieve this. If you use jquery,

$(document).ready(function() {
    $('.mydiv').click(function () {
        $('#form_id').submit();
    });
});
Anuj
  • 1,912
  • 1
  • 12
  • 19
  • Yes but want to do some refacto and look for the rails way – Arnaud Jeannin Mar 13 '19 at 08:24
  • afaik there's no helper for this. `f.submit` just creates an `` html tag, which is part of the html specification. The form action is already defined by the `form_with` tag. – Anuj Mar 13 '19 at 08:49