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, #tag_type, #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

#make_tag(appendix_tag = {}) ⇒ String

(AlOptions) HTMLタグの生成

Parameters:

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

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

Returns:

  • (String)

    htmlタグ



1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
# File 'lib/al_form.rb', line 1188

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

  r = %Q(<select name="#{@name}" id="#{@name}")
  make_tag_attr(r, appendix_tag)
  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