Class: Bureaucrat::Widgets::Input

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

Overview

Base class for input widgets

Direct Known Subclasses

FileInput, HiddenInput, PasswordInput, TextInput

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, #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

This class inherits a constructor from Bureaucrat::Widgets::Widget

Instance Method Details

#input_typeObject



65
66
67
# File 'lib/bureaucrat/widgets.rb', line 65

def input_type
  nil
end

#render(name, value, attrs = nil) ⇒ Object



56
57
58
59
60
61
62
63
# File 'lib/bureaucrat/widgets.rb', line 56

def render(name, value, attrs=nil)
  value ||= ''
  final_attrs = build_attrs(attrs,
                            type: input_type.to_s,
                            name: name.to_s)
  final_attrs[:value] = value.to_s unless value == ''
  mark_safe("<input#{flatatt(final_attrs)} />")
end