Class: AlSelector
Overview
Note:
チェックボックス、プルダウンメニュー、ラジオボタン
セレクタウィジェット スーパークラス
Direct Known Subclasses
Instance Attribute Summary (collapse)
-
- (Hash) options
readonly
選択項目のハッシュ.
-
- (String) separator
readonly
HTMLタグを生成する場合のタグ間セパレータ.
Instance Method Summary (collapse)
-
- (AlSelector) initialize(name, arg = {})
constructor
(AlSelector) constractor.
-
- (String) make_tag(arg = {})
(AlSelector) HTMLタグの生成.
-
- (String) make_value(*arg)
(AlSelector) HTML値の生成.
-
- (Object) set_value(v)
(also: #value=)
(AlSelector) 値のセット.
-
- (Boolean) validate
(AlSelector) バリデート.
Methods inherited from AlWidget
Constructor Details
- (AlSelector) initialize(name, arg = {})
(AlSelector) constractor
892 893 894 895 896 897 |
# File 'lib/al_form.rb', line 892 def initialize( name, arg = {} ) super( name, arg ) @options = arg[:options] @separator = arg[:separator] raise "Need ':options' parameter when make widget." if ! @options end |
Instance Attribute Details
- (Hash) options (readonly)
選択項目のハッシュ
877 878 879 |
# File 'lib/al_form.rb', line 877 def @options end |
- (String) separator (readonly)
HTMLタグを生成する場合のタグ間セパレータ
880 881 882 |
# File 'lib/al_form.rb', line 880 def separator @separator end |
Instance Method Details
- (String) make_tag(arg = {})
Note:
フラグ @hidden の時のみ対応。その他はサブクラスへ委譲。
(AlSelector) HTMLタグの生成
944 945 946 947 948 949 950 951 952 |
# File 'lib/al_form.rb', line 944 def make_tag( arg = {} ) @options.each do |k,v| if @value && @value.to_sym == k.to_sym return %Q(<input type="hidden" name="#{@name}" id="#{@name}" value="#{Alone::escape_html(k)}" #{AL_FORM_EMPTYTAG_CLOSE}\n) end end return "" end |
- (String) make_value(*arg)
(AlSelector) HTML値の生成
961 962 963 964 965 966 967 |
# File 'lib/al_form.rb', line 961 def make_value( *arg ) v = arg.empty? ? @value: arg[0] if v == "" || v == nil return "" end return Alone::escape_html( @options[v] || @options[v.to_sym] || @options[v.to_s] || @options[v.to_i] ) end |
- (Object) set_value(v) Also known as: value=
(AlSelector) 値のセット
905 906 907 |
# File 'lib/al_form.rb', line 905 def set_value( v ) @value = v.to_s end |
- (Boolean) validate
(AlSelector) バリデート
916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 |
# File 'lib/al_form.rb', line 916 def validate() @message = "" if @value == "" || @value == nil if @required @message = "#{@label}を選んでください。"; return false end return true end if ! @options[@value.to_sym] && ! @options[@value.to_s] && ! @options[@value.to_i] @message = "#{@label}の入力が、規定値以外です。"; return false end return true end |