Class: AlRadios

Inherits:
AlSelector show all
Defined in:
lib/al_form.rb

Overview

ラジオボタンウィジェット

Instance Attribute Summary

Attributes inherited from AlSelector

#options, #separator

Attributes inherited from AlWidget

#filter, #foreign, #hidden, #label, #message, #name, #required, #tag_attr, #value

Instance Method Summary (collapse)

Methods inherited from AlSelector

#initialize, #make_value, #set_value, #validate

Methods inherited from AlWidget

#initialize, #make_value, #set_attr, #set_value

Constructor Details

This class inherits a constructor from AlSelector

Instance Method Details

- (String) make_tag(arg = {})

(AlRadios) htmlタグの生成

Parameters:

  • arg (Hash) (defaults to: {})

    htmlタグへ追加するアトリビュートを指定

Returns:

  • (String)

    htmlタグ



1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
# File 'lib/al_form.rb', line 1174

def make_tag( arg = {} )
  return super( arg )  if @hidden

  r = ""
  @options.each do |k,v|
    checked = (@value && @value.to_s == k.to_s) ? " checked" : ""
    tagvalue = Alone::escape_html( k.to_s )
    r << %Q(<label><input type="radio" name="#{@name}" id="#{@name}_#{tagvalue}" value="#{tagvalue}"#{checked})
    (@tag_attr.merge arg).each do |k,v|
      r << %Q( #{k}="#{Alone::escape_html(v)}")
    end
    r << " #{AL_FORM_EMPTYTAG_CLOSE}#{Alone::escape_html(v)}</label>#{@separator}\n"
  end

  return r
end