Class: Forms::TimeZoneSelect
- Inherits:
-
Phlex::HTML
- Object
- Phlex::HTML
- Forms::TimeZoneSelect
- Includes:
- Phlex::Rails::Helpers::TimeZoneOptionsForSelect, PhlexForms::DelegatedField
- Defined in:
- lib/forms/time_zone_select.rb
Overview
A time-zone <select> populated by Rails' time_zone_options_for_select,
delegating the styling to DaisyUI::Select and wiring the tz Stimulus
controller (which auto-selects the browser's zone when none is set).
Requires phlex-rails' TimeZoneOptionsForSelect helper (a Rails host); outside
Rails, pass explicit choices to a plain Forms::Select instead.
Constant Summary
Constants included from PhlexForms::DelegatedField
PhlexForms::DelegatedField::IGNORED_MODIFIERS
Instance Method Summary collapse
-
#initialize(*modifiers, name: nil, id: nil, selected: nil, priority_zones: nil, model: ActiveSupport::TimeZone, placeholder: nil, include_blank: false, error: false, disabled: false, required: false, full_width: true, **attributes) ⇒ TimeZoneSelect
constructor
A new instance of TimeZoneSelect.
- #view_template ⇒ Object
Constructor Details
#initialize(*modifiers, name: nil, id: nil, selected: nil, priority_zones: nil, model: ActiveSupport::TimeZone, placeholder: nil, include_blank: false, error: false, disabled: false, required: false, full_width: true, **attributes) ⇒ TimeZoneSelect
Returns a new instance of TimeZoneSelect.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/forms/time_zone_select.rb', line 15 def initialize(*modifiers, name: nil, id: nil, selected: nil, priority_zones: nil, model: ActiveSupport::TimeZone, placeholder: nil, include_blank: false, error: false, disabled: false, required: false, full_width: true, **attributes) @modifiers = normalize_modifiers(modifiers) @name = name @id = id @selected = selected @priority_zones = priority_zones @zone_model = model @placeholder = placeholder @include_blank = include_blank @error = error @disabled = disabled @required = required @full_width = full_width @attributes = attributes super() end |
Instance Method Details
#view_template ⇒ Object
34 35 36 37 38 39 |
# File 'lib/forms/time_zone_select.rb', line 34 def view_template render DaisyUI::Select.new(*daisy_modifiers, **select_attributes) do |el| render_placeholder(el) if @placeholder || @include_blank el.raw(el.safe((@selected, @priority_zones, @zone_model))) end end |