Class: Forms::Radio

Inherits:
Phlex::HTML
  • Object
show all
Includes:
PhlexForms::DelegatedField
Defined in:
lib/forms/radio.rb

Overview

A model-bound radio input, delegating to DaisyUI::Radio.

Constant Summary

Constants included from PhlexForms::DelegatedField

PhlexForms::DelegatedField::IGNORED_MODIFIERS

Instance Method Summary collapse

Constructor Details

#initialize(*modifiers, name: nil, id: nil, value: nil, checked: false, error: false, disabled: false, required: false, **attributes) ⇒ Radio

Returns a new instance of Radio.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/forms/radio.rb', line 8

def initialize(*modifiers, name: nil, id: nil, value: nil, checked: false,
               error: false, disabled: false, required: false, **attributes)
  @modifiers = normalize_modifiers(modifiers)
  @name = name
  @id = id
  @value = value
  @checked = checked
  @error = error
  @disabled = disabled
  @required = required
  @full_width = false
  @attributes = attributes
  super()
end

Instance Method Details

#view_templateObject



23
24
25
26
27
# File 'lib/forms/radio.rb', line 23

def view_template
  attrs = binding_attributes
  attrs[:checked] = true if @checked
  render DaisyUI::Radio.new(*daisy_modifiers, value: @value, **attrs)
end