Sha256: fd97e7108851b7ef3f093897f6dc66354e920fff43fffe1e4ab481b750e7538c
Contents?: true
Size: 1.91 KB
Versions: 34
Compression:
Stored size: 1.91 KB
Contents
# frozen_string_literal: true module UiBibz::Ui::Core::Forms::Choices # Create a radio # # This element is an extend of UiBibz::Ui::Core::Component. # # ==== 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: # * +value+ - String, Integer, Boolean [required] # * +state+ - Symbol # (+:active+, +:disabled+) # * +inline+ - Boolean # * +action+ - String Stimulus Option # * +label+ - String # * +wrapper_html+: - Hash html_options for the wrapper # * +label_html+: - Hash html_options for the label # # ==== 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 # class RadioField < UiBibz::Ui::Core::Forms::Choices::CheckboxField # See UiBibz::Ui::Core::Component.initialize # Render html tag 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 def label_name html_options[:id] || "#{content}_#{options[:value]}" end end end
Version data entries
34 entries across 34 versions & 1 rubygems