pxs-forms 0.0.13 → 0.0.14

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8d50fc40d7619672b358b9a858d5fa475cad9c714e34b6b578e449972d092437
4
- data.tar.gz: ddd3bcd39966224b7c2eb2803b3ca1db2bd31ce7afa20c7b4e8d90e2bdd7a887
3
+ metadata.gz: bc5def5ec6debb0c7aa951c941634bbd4261c8edfa704d984c382f53cf25a6aa
4
+ data.tar.gz: cce8e5f438d488f989914f66303263187e20e2239883884ab0584d14a7006bad
5
5
  SHA512:
6
- metadata.gz: ce353d76d2f8363bd14a08899a8a96ccab5898bf73a1f819ea085aac5ffc7aa1f9d4be4d80d2db3fb259a90d9622917b107967d3ec7dd14545bd79c77774c369
7
- data.tar.gz: 4ab2e5a3b321f4808715402c5ed2b2fe351a165325051c7e3dca4ec06b1d1f5ba6831b289bba57aa357343295cc9f1981492256f20b97259340020e9d26108f0
6
+ metadata.gz: 65eca3c1a00da0d43541e9b0041ab9709c34f680c0ba78c81ab034f195cb335bdc7e6985206fb1556417a0202b2b5e62c4967ef4a2df0657672949b6401e4465
7
+ data.tar.gz: 750850a13d275c7a08c5ec393cc6cca5e862297244d9853ca82e47a9c3eff9e4c3e288ef52aa7b35d5af5c701a492bb169e6200d0d5794cca59479aa3b17a2d9
@@ -37,11 +37,9 @@ class ModelFormBuilder < ActionView::Helpers::FormBuilder
37
37
  @object.type_for_attribute(attribute.to_s).try(:type)
38
38
  # else if @object matches a column
39
39
  elsif @object.respond_to?(:column_for_attribute) && @object.has_attribute?(attribute)
40
- # return column type
41
40
  @object.column_for_attribute(attribute).try(:type)
42
41
  end
43
42
 
44
- # default to string
45
43
  result || :string
46
44
  end
47
45
 
@@ -51,7 +49,7 @@ class ModelFormBuilder < ActionView::Helpers::FormBuilder
51
49
  field_block(attribute, options) do
52
50
  safe_join [
53
51
  (field_label(attribute, options[:label]) unless options[:label] == false),
54
- string_field(attribute, merge_input_options({class: "#{"is-invalid" if has_error?(attribute)}"}, options)),
52
+ string_field(attribute, merge_input_options({class: "#{"is-invalid" if has_error?(attribute)}"}, options[:input_html])),
55
53
  ]
56
54
  end
57
55
  end
@@ -60,7 +58,7 @@ class ModelFormBuilder < ActionView::Helpers::FormBuilder
60
58
  field_block(attribute, options) do
61
59
  safe_join [
62
60
  (field_label(attribute, options[:label]) unless options[:label] == false),
63
- text_area(attribute, merge_input_options({class: "#{"is-invalid" if has_error?(attribute)}"}, options)),
61
+ text_area(attribute, merge_input_options({class: "#{"is-invalid" if has_error?(attribute)}"}, options[:input_html])),
64
62
  ]
65
63
  end
66
64
  end
@@ -69,21 +67,13 @@ class ModelFormBuilder < ActionView::Helpers::FormBuilder
69
67
  field_block(attribute, options) do
70
68
  tag.div(class: "checkbox-field") do
71
69
  safe_join [
72
- check_box(attribute, merge_input_options({class: "checkbox-input"}, options)),
70
+ check_box(attribute, merge_input_options({class: "checkbox-input"}, options[:input_html])),
73
71
  label(attribute, options[:label], class: "checkbox-label"),
74
72
  ]
75
73
  end
76
74
  end
77
75
  end
78
76
 
79
- def currency_input(attribute, options = {})
80
- field_block(attribute, options) do
81
- safe_join [
82
- (field_label(attribute, options[:label]) unless options[:label] == false), number_field(attribute, merge_input_options({class: "#{"is-invalid" if has_error?(attribute)}", step: "0.01", placeholder: "0.00"}, options))
83
- ]
84
- end
85
- end
86
-
87
77
  def collection_input(attribute, options, &block)
88
78
  field_block(attribute, options) do
89
79
  safe_join [
@@ -95,14 +85,14 @@ class ModelFormBuilder < ActionView::Helpers::FormBuilder
95
85
 
96
86
  def select_input(attribute, options = {})
97
87
 
98
- value_method = options[:value_method] || :to_s
99
- text_method = options[:text_method] || :to_s
88
+ value_method = options[:value_method] || :id
89
+ text_method = options[:text_method] || :name
100
90
  input_options = options || {}
101
91
 
102
92
  multiple = input_options[:multiple]
103
93
 
104
94
  collection_input(attribute, options) do
105
- collection_select(attribute, options[:collection], value_method, text_method, options, merge_input_options({class: "#{"custom-select" unless multiple} #{"is-invalid" if has_error?(attribute)}"}, options))
95
+ collection_select(attribute, options[:collection], value_method, text_method, options[:select_options] || {}, merge_input_options({class: "#{"custom-select" unless multiple} #{"is-invalid" if has_error?(attribute)}"}, options[:input_html]))
106
96
  end
107
97
  end
108
98
 
@@ -110,7 +100,7 @@ class ModelFormBuilder < ActionView::Helpers::FormBuilder
110
100
 
111
101
  # We probably need to go back later and adjust this for more customization
112
102
  collection_input(attribute, options) do
113
- grouped_collection_select(attribute, options[:collection], :last, :first, :to_s, :to_s, options, merge_input_options({class: "custom-select #{"is-invalid" if has_error?(attribute)}"}, options))
103
+ grouped_collection_select(attribute, options[:collection], :last, :first, :to_s, :to_s, options, merge_input_options({class: "custom-select #{"is-invalid" if has_error?(attribute)}"}, options[:input_html]))
114
104
  end
115
105
  end
116
106
 
@@ -197,7 +187,7 @@ class ModelFormBuilder < ActionView::Helpers::FormBuilder
197
187
 
198
188
  def error_text(attribute)
199
189
  if has_error? attribute
200
- tag.div @object.errors[method].join("<br />").html_safe, class: "form-errors"
190
+ tag.div @object.errors[attribute].join("<br />").html_safe, class: "form-errors"
201
191
  end
202
192
  end
203
193
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Pxs
4
4
  module Forms
5
- VERSION = "0.0.13"
5
+ VERSION = "0.0.14"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pxs-forms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.13
4
+ version: 0.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Poubelle
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-04-19 00:00:00.000000000 Z
11
+ date: 2024-05-02 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: