phlex-forms 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/forms/fields_for_builder.rb +2 -0
- data/lib/forms/form.rb +7 -0
- data/lib/forms/time_zone_select.rb +8 -1
- data/lib/phlex_forms/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c814b751d3d8dd050595b4d29aa7a261dd0b5dbb15787912a58e676fe09d76a9
|
|
4
|
+
data.tar.gz: 1c9bb1ff0df9584b34a7e9e67a4698a04569d985b0406f9e9d79e60d2abe160f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6d86f0ca8fa5497a118b5e137e9bd23b67a68b4db6076cad19a38d6dc4bad4e3d42a5b3958077666e5f1370658b6069dc9787d816c3904c4717c5f5725d7cac0
|
|
7
|
+
data.tar.gz: fbe09ab98824da11331b9a6d4abaf502356bb617157b12a68a82096eab790b2d5e794bd2457e8ccd94651e418b69dbab76317e3bfb6542f7dfe7d60d37479d25
|
|
@@ -8,6 +8,7 @@ module Forms
|
|
|
8
8
|
include PhlexForms::Builder
|
|
9
9
|
|
|
10
10
|
attr_reader :model, :scope, :errors, :parent_form
|
|
11
|
+
alias object model # Rails form-builder compatibility (mirrors Forms::Form)
|
|
11
12
|
|
|
12
13
|
def initialize(model:, scope:, errors:, parent_form:)
|
|
13
14
|
@model = model
|
|
@@ -24,6 +25,7 @@ module Forms
|
|
|
24
25
|
def field_object(name, error_name: nil)
|
|
25
26
|
Forms::Field.new(name:, model: @model, scope: @scope, errors: @errors, form: @parent_form, error_name:)
|
|
26
27
|
end
|
|
28
|
+
alias [] field_object # `item_form[:id].hidden` — Rails form-builder-style access
|
|
27
29
|
|
|
28
30
|
def default_field_variants
|
|
29
31
|
@parent_form.default_field_variants
|
data/lib/forms/form.rb
CHANGED
|
@@ -19,6 +19,12 @@ module Forms
|
|
|
19
19
|
|
|
20
20
|
attr_reader :model, :scope, :url, :method, :errors, :validate, :theme
|
|
21
21
|
|
|
22
|
+
# Rails form-builder compatibility: `f.object` / `f.object_name` mirror the
|
|
23
|
+
# ActionView FormBuilder API so call sites that introspect the bound record
|
|
24
|
+
# (`f.object.class.reflect_on_association(...)`) keep working.
|
|
25
|
+
alias object model
|
|
26
|
+
alias object_name scope
|
|
27
|
+
|
|
22
28
|
def initialize(*modifiers, model: nil, scope: nil, url: nil, method: nil, validate: false,
|
|
23
29
|
field_variants: nil, theme: nil, live: nil, **options)
|
|
24
30
|
if live
|
|
@@ -66,6 +72,7 @@ module Forms
|
|
|
66
72
|
def field_object(name, error_name: nil)
|
|
67
73
|
Forms::Field.new(name:, model: @model, scope: @scope, errors: @errors, form: self, error_name:)
|
|
68
74
|
end
|
|
75
|
+
alias [] field_object # `f[:email].hidden` — Rails form-builder-style access
|
|
69
76
|
|
|
70
77
|
def submit(*, **, &)
|
|
71
78
|
render theme[:submit].new(*, model: @model, **, &)
|
|
@@ -32,9 +32,16 @@ module Forms
|
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
def view_template
|
|
35
|
+
# Build the options on `self` — the TimeZoneOptionsForSelect helper is
|
|
36
|
+
# included here, NOT on the yielded DaisyUI::Select (`el`), so calling it
|
|
37
|
+
# inside the block would raise NoMethodError.
|
|
38
|
+
# time_zone_options_for_select returns an HTML-safe buffer; Phlex's `safe`
|
|
39
|
+
# expects a plain String, so coerce with #to_s before marking it safe.
|
|
40
|
+
options_html = time_zone_options_for_select(@selected, @priority_zones, @zone_model).to_s
|
|
41
|
+
|
|
35
42
|
render DaisyUI::Select.new(*daisy_modifiers, **select_attributes) do |el|
|
|
36
43
|
render_placeholder(el) if @placeholder || @include_blank
|
|
37
|
-
el.raw(el.safe(
|
|
44
|
+
el.raw(el.safe(options_html))
|
|
38
45
|
end
|
|
39
46
|
end
|
|
40
47
|
|
data/lib/phlex_forms/version.rb
CHANGED