Class: AlTextArea

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

Overview

テキストエリアウィジェット

Instance Method Summary (collapse)

Methods inherited from AlText

#set_value, #validate

Methods inherited from AlWidget

#set_attr, #set_value

Constructor Details

- (AlTextArea) initialize(name, arg = {})

(AlTextArea) constractor

Parameters:

  • (String) name

    ウィジェット識別名 英文字を推奨

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

    引数ハッシュ

Options Hash (arg):

  • (Integer) :rows N/A

    行数

  • (Integer) :cols N/A

    列数

See Also:



825
826
827
828
829
830
831
832
# File 'lib/al_form.rb', line 825

def initialize( name, arg = {} )
  super( name, arg )
  @validator = arg[:validator] || /[^\x00-\x08\x0B\x0C\x0E-\x1F\x7F]/

  # html必須属性(rows, cols)のセット
  @tag_attr[:rows] = arg[:rows] || 3
  @tag_attr[:cols] = arg[:cols] || 40
end

Instance Method Details

- (String) make_tag(arg = {})

(AlTextArea) HTMLタグの生成

Parameters:

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

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

Returns:

  • (String)

    htmlタグ



841
842
843
844
845
846
847
848
849
# File 'lib/al_form.rb', line 841

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

  r = %Q(<textarea name="#{@name}" id="#{@name}")
  (@tag_attr.merge arg).each do |k,v|
    r << %Q( #{k}="#{Alone::escape_html(v)}")
  end
  return r + ">#{Alone::escape_html( @value )}</textarea>\n"
end

- (String) make_value(*arg)

Note:

改行を
タグに変換しながら出力する。

(AlTextArea) HTML値の生成

Parameters:

  • (String) arg

    表示値。指定なければ内部値を使う。

Returns:

  • (String)

    html文字列



860
861
862
# File 'lib/al_form.rb', line 860

def make_value( *arg )
  return Alone::escape_html_br( arg.empty? ? @value: arg[0] )
end