Class: AlFile
- Inherits:
-
AlWidget
- Object
- AlWidget
- AlFile
- Defined in:
- lib/al_form.rb,
lib/al_form/input_file.rb
Overview
ファイルウィジェット
Instance Method Summary (collapse)
-
- (AlFile) initialize(name, arg = {})
constructor
(AlFile) constractor.
-
- (String) make_tag(arg = {})
(AlFile) HTMLタグの生成.
-
- (Boolean) validate
(AlFile) バリデート.
Methods inherited from AlWidget
#make_value, #set_attr, #set_value
Constructor Details
- (AlFile) initialize(name, arg = {})
(AlFile) constractor
1202 1203 1204 1205 1206 |
# File 'lib/al_form.rb', line 1202 def initialize( name, arg = {} ) require 'al_form/input_file' super( name, arg ) end |
Instance Method Details
- (String) make_tag(arg = {})
Note:
hiddenフラグは未対応。type=“file”は動作が特殊なので、hiddenにする意味がない。
(AlFile) HTMLタグの生成
47 48 49 50 51 52 53 |
# File 'lib/al_form/input_file.rb', line 47 def make_tag( arg = {} ) r = %Q(<input type="file" name="#{@name}" ) (@tag_attr.merge arg).each do |k,v| r << %Q( #{k}="#{Alone::escape_html(v)}") end return "#{r} #{AL_FORM_EMPTYTAG_CLOSE}" end |
- (Boolean) validate
(AlFile) バリデート
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/al_form/input_file.rb', line 22 def validate() @message = "" if @value.class != Hash raise "AlFile needs \@value by hash obj. #{@value.class} given, now. Maybe enctype is not multipart/form-data." end if @value[:size] == 0 if @required @message = "#{@label}を指定してください。" return false end end return true end |