Skip to content

Instantly share code, notes, and snippets.

@SamuelAierizer
SamuelAierizer / _form.html.erb
Created September 17, 2021 14:01
Stimulus select based toggle of input options
<div data-controller="select">
<%= select_tag(:question_type, options_for_select([['Multiple choice with 1 answer', 'radial'], ['Multiple choice with multiple answers', 'checkbox'], ['Open answer', 'open']], 'open'), {:class => 'form-field', "data-select-target" => "select", "data-action" => "change->select#changed"}) %>
<div data-select-target="single">
<p> Insert here for single option which will ocure if choosen 'open' </p>
</div>
<div data-select-target="multi">
<p> Insert here for multi option which will ocure if choosen enethyng else </p>
</div>