class UiBibz::Ui::Core::Forms::Texts::TextField

Create a TextField

This element is an extend of UiBibz::Ui::Core::Component.

Attributes

Options

You can add HTML attributes using the html_options. You can pass arguments in options attribute:

String, Html

Signatures

UiBibz::Ui::Core::Forms::Texts::TextField.new(content, options = {}, html_options = {}).render

UiBibz::Ui::Core::Forms::Texts::TextField.new(options = {}, html_options = {}) do
  content
end.render

Examples

UiBibz::Ui::Core::Forms::Texts::TextField.new('search', prepend: 'Prepend content', append: 'Append content', class: 'test')

UiBibz::Ui::Core::Forms::Texts::TextField.new(prepend: glyph('pencil'), append: glyph('camera-retro')) do
  #content
end

Helper

text_field(options = {}, html_options = {}) do
 # content
end

Public Instance Methods

pre_render() click to toggle source

Render html tag

# File lib/ui_bibz/ui/core/forms/texts/text_field.rb, line 53
def pre_render
  surround_field text_field_input_tag
end

Private Instance Methods

component_html_classes() click to toggle source
# File lib/ui_bibz/ui/core/forms/texts/text_field.rb, line 69
def component_html_classes
  super << ['form-control', status, size]
end
component_html_options() click to toggle source
# File lib/ui_bibz/ui/core/forms/texts/text_field.rb, line 73
def component_html_options
  options[:state] == :disabled ? { disabled: 'disabled' } : {}
end
component_options() click to toggle source

Todo

# File lib/ui_bibz/ui/core/forms/texts/text_field.rb, line 65
def component_options
  options[:status].nil? ? super : super.merge({ surrounded: true })
end
size() click to toggle source
# File lib/ui_bibz/ui/core/forms/texts/text_field.rb, line 81
def size
  "form-control-#{options[:size]}" unless options[:size].nil?
end
status() click to toggle source
# File lib/ui_bibz/ui/core/forms/texts/text_field.rb, line 77
def status
  "form-control-#{options[:status]}" unless options[:status].nil?
end
text_field_input_tag() click to toggle source

Simple_form or not

# File lib/ui_bibz/ui/core/forms/texts/text_field.rb, line 60
def text_field_input_tag
  text_field_tag content, options[:value] || html_options[:value], html_options
end