class UiBibz::Ui::Core::Forms::Surrounds::SurroundField

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:

Signatures

UiBibz::Ui::Core::Forms::Surrounds::Surround.new(options = {}, html_options = {}) do |s|
  s.
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

Attributes

errors[R]
required_fields[R]

Public Class Methods

new(content = nil, options = nil, html_options = nil, &block) click to toggle source

See UiBibz::Ui::Core::Component.initialize

Calls superclass method UiBibz::Ui::Core::Component::new
# File lib/ui_bibz/ui/core/forms/surrounds/surround_field.rb, line 55
def initialize(content = nil, options = nil, html_options = nil, &block)
  super
  @items = []
  @errors = []
  @required_fields = []
end

Public Instance Methods

addon(content = nil, options = {}, html_options = nil, &block) click to toggle source
# File lib/ui_bibz/ui/core/forms/surrounds/surround_field.rb, line 82
def addon(content = nil, options = {}, html_options = nil, &block)
  @items << SurroundAddon.new(content, options, html_options, &block).render
end
auto_complete_field(content = nil, options = nil, html_options = nil, &block) click to toggle source
# File lib/ui_bibz/ui/core/forms/surrounds/surround_field.rb, line 127
def auto_complete_field(content = nil, options = nil, html_options = nil, &block)
  @items << UiBibz::Ui::Core::Forms::Texts::AutoCompleteField.new(content, options, html_options, &block).render
end
button(content = nil, options = nil, html_options = nil, &block) click to toggle source
# File lib/ui_bibz/ui/core/forms/surrounds/surround_field.rb, line 86
def button(content = nil, options = nil, html_options = nil, &block)
  @items << SurroundButton.new(content, options, html_options, &block).render
end
button_group(content = nil, options = nil, html_options = nil, &block) click to toggle source
# File lib/ui_bibz/ui/core/forms/surrounds/surround_field.rb, line 90
def button_group(content = nil, options = nil, html_options = nil, &block)
  @items << SurroundButtonGroup.new(content, options, html_options).tap(&block).render
end
button_refresh(content = nil, options = nil, html_options = nil, &block) click to toggle source
# File lib/ui_bibz/ui/core/forms/surrounds/surround_field.rb, line 98
def button_refresh(content = nil, options = nil, html_options = nil, &block)
  @items << SurroundButtonRefresh.new(content, options, html_options, &block).render
end
checkbox_field(content = nil, options = nil, html_options = nil, &block) click to toggle source
# File lib/ui_bibz/ui/core/forms/surrounds/surround_field.rb, line 102
def checkbox_field(content = nil, options = nil, html_options = nil, &block)
  @items << SurroundCheckboxField.new(content, options, html_options, &block).render
end
date_picker_field(content = nil, options = nil, html_options = nil, &block) click to toggle source
# File lib/ui_bibz/ui/core/forms/surrounds/surround_field.rb, line 114
def date_picker_field(content = nil, options = nil, html_options = nil, &block)
  @items << UiBibz::Ui::Core::Forms::Dates::DatePickerField.new(content, options, html_options, &block).render
end
dropdown(content, options = nil, html_options = nil, &block) click to toggle source
dropdown_select_field(content = nil, options = nil, html_options = nil, &block) click to toggle source
glyph(content = nil, options = {}, html_options = nil, &block) click to toggle source
# File lib/ui_bibz/ui/core/forms/surrounds/surround_field.rb, line 78
def glyph(content = nil, options = {}, html_options = nil, &block)
  @items << SurroundAddon.new(UiBibz::Ui::Core::Icons::Glyph.new(content, options, html_options, &block).render).render
end
input(attribute_name, options = {}, &block) click to toggle source
# File lib/ui_bibz/ui/core/forms/surrounds/surround_field.rb, line 71
def input(attribute_name, options = {}, &block)
  @items << @options[:form].input(attribute_name, options.merge({ label: false, wrapper: false, error: false }), &block)
  obj = @options[:form].object
  @errors << obj.errors[attribute_name] unless obj.errors[attribute_name].empty?
  @required_fields << (obj._validators[attribute_name].try(:first).class.to_s == 'ActiveRecord::Validations::PresenceValidator')
end
pre_render() click to toggle source

Render html tag

# File lib/ui_bibz/ui/core/forms/surrounds/surround_field.rb, line 63
def pre_render
  content_tag :div, @items.join.html_safe, html_options
end
radio_field(content = nil, options = nil, html_options = nil, &block) click to toggle source
# File lib/ui_bibz/ui/core/forms/surrounds/surround_field.rb, line 106
def radio_field(content = nil, options = nil, html_options = nil, &block)
  @items << SurroundRadioField.new(content, options, html_options, &block).render
end
select_field(content = nil, options = nil, html_options = nil, &block) click to toggle source
# File lib/ui_bibz/ui/core/forms/surrounds/surround_field.rb, line 123
def select_field(content = nil, options = nil, html_options = nil, &block)
  @items << UiBibz::Ui::Core::Forms::Selects::SelectField.new(content, options, html_options, &block).render
end
text_field(content = nil, options = nil, html_options = nil, &block) click to toggle source
# File lib/ui_bibz/ui/core/forms/surrounds/surround_field.rb, line 110
def text_field(content = nil, options = nil, html_options = nil, &block)
  @items << UiBibz::Ui::Core::Forms::Texts::TextField.new(content, options, html_options, &block).render
end

Private Instance Methods

component_html_classes() click to toggle source

Not correctly implemented def switch_field content = nil, options = nil, html_options = nil, &block

@items << SurroundSwitchField.new(content, options, html_options, &block).render

end

# File lib/ui_bibz/ui/core/forms/surrounds/surround_field.rb, line 138
def component_html_classes
  ['input-group', status, size, 'ui_surround_field']
end
size() click to toggle source

:lg, :sm or :xs

# File lib/ui_bibz/ui/core/forms/surrounds/surround_field.rb, line 143
def size
  "input-group-#{options[:size]}" if options[:size]
end
status() click to toggle source
# File lib/ui_bibz/ui/core/forms/surrounds/surround_field.rb, line 147
def status
  "has-#{options[:status]}" if options[:status]
end