Class: AlTextArea

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

Overview

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

Instance Attribute Summary

Attributes inherited from AlText

#max, #min, #validator

Attributes inherited from AlWidget

#filter, #foreign, #hidden, #label, #message, #name, #required, #tag_attr, #tag_type, #value

Instance Method Summary collapse

Methods inherited from AlText

#set_value, #validate

Methods inherited from AlWidget

#set_attr, #set_value

Constructor Details

#initialize(name, arg = {}) ⇒ AlTextArea

(AlTextArea) constructor

Parameters:

  • name (String)

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

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

    引数ハッシュ

Options Hash (arg):

  • :rows (Integer)

    行数

  • :cols (Integer)

    列数

See Also:



878
879
880
881
882
883
884
885
# File 'lib/al_form.rb', line 878

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

#make_tag(appendix_tag = {}) ⇒ String

(AlTextArea) HTMLタグの生成

Parameters:

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

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

Returns:

  • (String)

    htmlタグ



894
895
896
897
898
899
900
901
# File 'lib/al_form.rb', line 894

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

  r = %Q(<textarea name="#{@name}" id="#{@name}")
  make_tag_attr(r, appendix_tag)
  r << ">#{Alone::escape_html( @value )}</textarea>\n"
  return r
end

#make_value(*arg) ⇒ String

Note:

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

(AlTextArea) HTML値の生成

Parameters:

  • arg (String)

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

Returns:

  • (String)

    html文字列



911
912
913
# File 'lib/al_form.rb', line 911

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