Radio Buttons?

57 views
Skip to first unread message

geoffd123

unread,
Apr 28, 2009, 6:37:27 AM4/28/09
to Hobo Users
Is there any support for Radio buttons in Hobo, I cannot seem to find
a tag similar to <select> that supports radio buttons instead.

I want to implement something alone the lines of <select-one> on a
collection, but called <check-one>

Cheers
Geoff

Tom Locke

unread,
Apr 28, 2009, 6:38:31 AM4/28/09
to hobo...@googlegroups.com
No we don't have that yet

T

geoffd123

unread,
Apr 28, 2009, 6:45:14 AM4/28/09
to Hobo Users
Ok, I will have a go add creating something.

Gert Thiel

unread,
Apr 28, 2009, 8:16:11 AM4/28/09
to Hobo Users
Hoi.

I've written something like

<def tag="input" for="HoboFields::TaxEntitlement" attrs="labels,
titleize"><%
labels ||= {}
titleize = true if titleize.nil?
options = HoboFields::TaxEntitlement::TAX_ENTITLEMENTS
options.each do |o|
%>
<p><%= radio_button_tag(param_name_for_this, o[1], (o[1] == this))
%> <span><%= o[0] %></span></p>
<% end %>
</def>

for my own rich type HoboFields::TaxEntitlement.

—Gert

Bryan Larsen

unread,
Apr 28, 2009, 12:02:11 PM4/28/09
to hobo...@googlegroups.com
If you convert that into a general tag I can throw that into
hobo-contrib or maybe even into Rapid itself...

First pass (probably won't even compile):

<def tag="radio-button" attrs="option">
<%= radio_button_tag(param_name_for_this, option, (option==this),
attributes) %>
</def>

<def tag="radio-button-item" attrs="option, id">
<radio-button option="&option" value="&value" id="&id" param />
<label for="&id" param />
</def>

<def tag="radio-group" attrs="options, labels">
<% labels ||= [] %>
<% options.each_with_index do |option, index| -%>
<radio-button-item option="&option"
id="#{param_name_for_this}[#{index}]">
<label:><%= labels[index] || option %></label:>
</radio-button-item>
</def>

and to use

<def tag="input" for "ArticleStatus">
<radio-group options="ArticleStatus.values">
</def>

The user would probably want to extend radio-button-item as well....

Bryan
Reply all
Reply to author
Forward
0 new messages