Rails 5: Pass value from static HTML element to embedded Ruby method in ERB

186 views Asked by At

I have a form with some static HTML and embedded Rails form helpers and I'd like to pass the value of an element in the static HTML as a parameter to a method defined in an embedded form helper tag:

<div class="field">
    <input type="radio" name="filter_param" value="a">A</input>
    <input type="radio" name="filter_param" value="b">B</input>
    <input type="radio" name="filter_param" value="c">C</input>
</div>

<div class="field">
  <%= f.select(:things, ThingsHelper.all_the_things(filter_param: ...), {required: true, include_blank: 'Select a thing.'}) %>
</div>

Is it possible to replace the ... in the example above with something that references with filter_param value from the static HTML?

If not what's the best or most Rails friendly way to solve this? JavaScript?

0

There are 0 answers