class UiBibz::Ui::Core::Forms::Choices::RadioField

Create a radio

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::RadioField.new(content, options = nil, html_options = nil)

UiBibz::Ui::Core::Forms::RadioField.new(options = nil, html_options = nil) do
  content
end

Examples

UiBibz::Ui::Core::Forms::RadioField.new(content, { inline: true },{ class: 'test' }).render

UiBibz::Ui::Core::Forms::RadioField.new({ label: "My Radio" }, { class: 'test' }) do
  content
end.render

Helper

ui_radio_field(content, options = {}, html_options = {})

ui_radio_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/choices/radio_field.rb, line 55
def pre_render
  content_tag :div, wrapper_html_options do
    concat radio_button_tag content, options[:value], options[:checked] || false, checkbox_html_options
    concat label_tag(label_name, label_content, class: 'form-check-label') if options[:label] != false
  end
end

Private Instance Methods

label_name() click to toggle source
# File lib/ui_bibz/ui/core/forms/choices/radio_field.rb, line 64
def label_name
  html_options[:id] || "#{content}_#{options[:value]}"
end