Option
The HTML <option> tag, implemented in Ruby.
Parameters
This component can take 7 optional configuration params and either yield content or display what gets passed to the text configuration param.
id (optional)
Expects a string with all ids the <option> should have.
class (optional)
Expects a string with all classes the <option> should have.
disabled (optional)
Specifies that the <option> should be disabled.
label (optional)
Specifies a shorter label for the <option>.
text (optional)
Specifies the text the <option> should contain.
selected (optional)
Specifies that the <option> should be pre-selected when the page loads.
value (optional)
Specifies the value to be sent to a server.
Example 1: Render options[:text] param
options[:text] paramoption text: 'Option 1'returns
<option>Option 1</option>Example 2: Render options[:label] param
options[:label] paramoption label: 'Option 2'returns
<option label="Option 2"></option>Example 3: Render with more attributes
option disabled: true, label: 'Option 3', selected: true, value: '3'returns
<option disabled="disabled" label="Option 3" selected="selected" value="3"></option>Example 4: Yield a given block
option id: 'foo', class: 'bar' do
plain 'Option 4'
endreturns
<option id="foo" class="bar">
Option 4
</option>Last updated
Was this helpful?