class UiBibz::Ui::Core::Forms::Choices::Choice
Create a choice
This element is an extend of UiBibz::Ui::Core::Forms::Choices::Button
Attributes¶ ↑
-
content
- Content of element -
options
- Options of element -
html_options
- Html Options of element
Options¶ ↑
You can add HTML attributes using the html_options
. You can pass arguments in options attribute:
-
status
- status of element with symbol value: (:primary
,:secondary
,:info
,:warning
,:danger
) -
outline
- Boolean -
state
- Symbol (:active
, +:disabled) -
type
- Symbol (+:block) -
name
- String name of input checkbox -
id
- String id of input checkbox -
input_html_options
- Hash of input html options -
glyph
- Add glyph with name or hash options-
name
- String -
size
- Integer -
type
- Symbol
-
Signatures¶ ↑
UiBibz::Ui::Core::Forms::Choices::Choice.new(content, options = nil, html_options = nil) UiBibz::Ui::Core::Forms::Choices::Choice.new(options = nil, html_options = nil) do content end
Examples¶ ↑
UiBibz::Ui::Core::Forms::Choices::Choice.new('test', state: :active) UiBibz::Ui::Core::Forms::Choices::Choice.new({id: 'state', input_html_options: { class: 'state'}}, { class: 'lable-class'}) do test end.render
Helper¶ ↑
choice(content, options = {}, html_options = {}) choice(options = {}, html_options = {}) do content end
Public Instance Methods
input_options()
click to toggle source
# File lib/ui_bibz/ui/core/forms/choices/components/choice.rb, line 63 def input_options @input_options ||= { type: type, autocomplete: :off, class: 'btn-check' } .merge(checked) .merge(value) .merge(name) .merge({ id: input_id }) .merge(input_html_options) end
pre_render()
click to toggle source
Render html tag
# File lib/ui_bibz/ui/core/forms/choices/components/choice.rb, line 59 def pre_render button_choice_html_tag end
Private Instance Methods
checked()
click to toggle source
# File lib/ui_bibz/ui/core/forms/choices/components/choice.rb, line 96 def checked @options[:state] == :active ? { checked: :checked } : {} end
generated_label()
click to toggle source
# File lib/ui_bibz/ui/core/forms/choices/components/choice.rb, line 89 def generated_label content_tag :label, html_options.merge(for: input_id) do concat glyph_and_content_html(options[:text].nil? ? @content : ' ') concat badge_html unless options[:badge].nil? end end
input_html_options()
click to toggle source
# File lib/ui_bibz/ui/core/forms/choices/components/choice.rb, line 108 def input_html_options @options[:input_html_options].nil? ? {} : @options[:input_html_options] end
input_id()
click to toggle source
# File lib/ui_bibz/ui/core/forms/choices/components/choice.rb, line 120 def input_id @input_id ||= @options[:id] || generate_id('choice') end
label_tag()
click to toggle source
# File lib/ui_bibz/ui/core/forms/choices/components/choice.rb, line 81 def label_tag if options[:label] content_tag :label, options[:label], html_options.merge(for: input_id) else generated_label end end
name()
click to toggle source
# File lib/ui_bibz/ui/core/forms/choices/components/choice.rb, line 104 def name @options[:name].nil? ? {} : { name: @options[:name] } end
state()
click to toggle source
# File lib/ui_bibz/ui/core/forms/choices/components/choice.rb, line 124 def state; end
status()
click to toggle source
# File lib/ui_bibz/ui/core/forms/choices/components/choice.rb, line 116 def status ['btn', outline, options[:status] || :secondary].compact.join('-') end
type()
click to toggle source
# File lib/ui_bibz/ui/core/forms/choices/components/choice.rb, line 112 def type @options[:type] || :checkbox end
value()
click to toggle source
# File lib/ui_bibz/ui/core/forms/choices/components/choice.rb, line 100 def value @options[:value].nil? ? {} : { value: options[:value] } end