Class: AlOptions

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 = {})

(AlOptions) HTMLタグの生成

Parameters:

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

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

Returns:

  • (String)

    htmlタグ



1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
# File 'lib/al_form.rb', line 1143

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

  r = %Q(<select name="#{@name}" id="#{@name}")
  (@tag_attr.merge arg).each do |k,v|
    r << %Q( #{k}="#{Alone::escape_html(v)}")
  end
  r << ">\n"
  @options.each do |k,v|
    selected = (@value && @value.to_s == k.to_s) ? " selected": ""
    tagvalue = Alone::escape_html( k.to_s )
    r << %Q(<option id="#{name}_#{tagvalue}" value="#{tagvalue}"#{selected}>#{Alone::escape_html(v)}</option>\n)
  end
  return r + "</select>\n"
end