x
1
2
3
4
<form action="#" accept-charset="UTF-8" method="post"><input type="hidden" name="authenticity_token" value="Npy-7RQ6EEcBaJB8nfRisPcU4t6EoRhsfCkBHwijwwxerjC1uVqRyDqDZ6bFvXn1zx0iQ3s48SCLX9h9slUHAg" autocomplete="off" /> <label class="rpf-input-radio"><input id="berry_raspberry" name="berry" type="radio" value="raspberry">Raspberry</label> <label class="rpf-input-radio"><input id="berry_gooseberry" name="berry" type="radio" value="gooseberry">Gooseberry</label></form>
1
2
3
4
<%= form_with url: '#', builder: DesignSystem::FormBuilder do |f| %> <%= f.rpf_radio_input :berry, value: 'raspberry', label: 'Raspberry', checked:, modifiers:, **attrs %> <%= f.rpf_radio_input :berry, value: 'gooseberry', label: 'Gooseberry', modifiers:, **attrs %><% end %>
Radio Input Component (without model)
rpf_radio_input(:name, label:, checked: false, modifiers: nil, **attrs)
This is very similar to the radio input component with a
model, but instead the first argument is used as the name
attribute.
<%= form_with url: '#', builder: DesignSystem::FormBuilder do |f| %> <%= f.rpf_radio_input(:berry, value: 'raspberry', label: 'Raspberry', checked: true) %> <%= f.rpf_radio_input(:berry, value: 'gooseberry', label: 'Gooseberry') %><% end %>
produces:
<!-- form opening tag goes here ---><label class="rpf-input-radio"> <input id="berry_raspberry" name="berry" type="radio" value="raspberry"> Raspeberry</label><label class="rpf-input-radio"> <input id="berry_gooseberry" name="berry" type="radio" value="gooseberry"> Gooseberry</label>
This is based on DesignSystem::Form::RadioInputComponent and the same arguments are used in both.
Arguments
name
- The name in the radio input.value
- The value of the radio input.label:
- The text to display next to the radio.checked:
- Set the checked state.modifiers:
- Additional classes to apply to the radio, e.g.:disabled
or:'full-width'
It also accepts all the usual HTML attributes for a radio input, e.g. id
, class
, data-
etc.
Param | Description | Input |
---|---|---|
— |
|
|
— |
|