Class: Bureaucrat::Widgets::Textarea

Inherits:
Widget
  • Object
show all
Defined in:
lib/bureaucrat/widgets.rb

Constant Summary

Constant Summary

Constants included from Utils

Utils::ESCAPES

Instance Attribute Summary

Attributes inherited from Widget

#attrs, #is_required

Instance Method Summary (collapse)

Methods inherited from Widget

#build_attrs, #has_changed?, #hidden?, id_for_label, #initialize_copy, #needs_multipart?, #value_from_formdata

Methods included from Utils

#blank_value?, #conditional_escape, #escape, #flatatt, #format_string, #make_bool, #make_float, #mark_safe, #pretty_name

Constructor Details

- (Textarea) initialize(attrs = nil)



241
242
243
244
245
246
247
# File 'lib/bureaucrat/widgets.rb', line 241

def initialize(attrs=nil)
  # The 'rows' and 'cols' attributes are required for HTML correctness.
  default_attrs = {cols: '40', rows: '10'}
  default_attrs.merge!(attrs) if attrs

  super(default_attrs)
end

Instance Method Details

- (Object) render(name, value, attrs = nil)



249
250
251
252
253
# File 'lib/bureaucrat/widgets.rb', line 249

def render(name, value, attrs=nil)
  value ||= ''
  final_attrs = build_attrs(attrs, name: name)
  mark_safe("<textarea#{flatatt(final_attrs)}>#{conditional_escape(value.to_s)}</textarea>")
end