Class: Proscenium::UI::Form::Fields::RadioInput

Inherits:
Base
  • Object
show all
Defined in:
lib/proscenium/ui/form/fields/radio_input.rb

Instance Attribute Summary

Attributes inherited from Base

#attribute, #attributes, #form, #model

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Proscenium::UI::Form::Fields::Base

Instance Method Details

#view_templateObject



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/proscenium/ui/form/fields/radio_input.rb', line 5

def view_template
  checked = attributes[:value].to_s == value.to_s

  default = model.class.human_attribute_name("#{attribute.join('.')}.#{attributes[:value]}")
  label_contents = attributes.delete(:label) || translate_label(default:)

  label do |_|
    input(name: field_name, type: :radio, checked:, **build_attributes)
    span { label_contents }
  end
end