chobble-forms 0.8.0 → 0.9.0

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: 5278667464b4fb04d365ef198a36874fec3f5590680f705a18b0d5133776e201
4
- data.tar.gz: 565d3f9a541a8e5aa5ce91fe0a2394afe2284c449103664785b5bca2a80123ef
3
+ metadata.gz: ab593ac41bb229464108cac7259b52c2651befb209718e10c64c623d6b80750f
4
+ data.tar.gz: 4036dcb72c51dd939694f4032f36080d38be629a6f98d28140e1cec1f202c1bf
5
5
  SHA512:
6
- metadata.gz: bc9e9c26ef8f0072faa78015d29783b1dd899269d82cc4a2f33f63311ba0714e7a4a20540a0c7e0d6723858070d722a06e19c939565c406eb6f3b81be27bef16
7
- data.tar.gz: 3c869b047f9ae812878c8a7b1be78533a25bef9280fbd9b9860d2dfbc5aca51f01e85d33af9d54b8db750f64754765d6c95cd219f61196ff739246948487be93
6
+ metadata.gz: 15d8ee8a1dd9c086cd17da51d951af54967f260e1be46d33d469d1a1b2cd2c3091cfaea48199c0ae3e297d7100b9784d921da3bd3a16392ecef1f908ee5212be
7
+ data.tar.gz: 2955ec5e0fb1881cdbac8ca0957b452ea8a8b5924c4f7c54706f93949c6879e7494d6542172414bf945018a0bf0a65ac5a0ca94f8bd79bf5f4913aebe89bd9c1
@@ -117,6 +117,7 @@ module ChobbleForms
117
117
  ALLOWED_LOCAL_ASSIGNS = T.let(%i[
118
118
  accept
119
119
  add_not_applicable
120
+ combobox
120
121
  field
121
122
  max
122
123
  min
@@ -127,6 +128,7 @@ module ChobbleForms
127
128
  rows
128
129
  step
129
130
  type
131
+ value
130
132
  ].freeze, T::Array[Symbol])
131
133
 
132
134
  sig { params(local_assigns: T::Hash[Symbol, LocalAssignValue]).void }
@@ -2,5 +2,5 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module ChobbleForms
5
- VERSION = "0.8.0"
5
+ VERSION = "0.9.0"
6
6
  end
@@ -2,17 +2,21 @@
2
2
  # Get i18n_base from section (already validated there)
3
3
  setup = form_field_setup(field, local_assigns)
4
4
 
5
- # Get value from model object automatically
6
- model_object = setup[:form_object].object
7
- value = model_object.send(field) if model_object.respond_to?(field)
5
+ # Use provided value parameter if present, otherwise get from model
6
+ if local_assigns.key?(:value)
7
+ display_value = value
8
+ else
9
+ model_object = setup[:form_object].object
10
+ display_value = model_object.send(field) if model_object.respond_to?(field)
11
+ end
8
12
 
9
13
  # Format dates and times nicely
10
- formatted_value = if value.is_a?(DateTime) || value.is_a?(Time)
11
- value.strftime("%B %-d, %Y - %H:%M")
12
- elsif value.is_a?(Date)
13
- value.strftime("%B %-d, %Y")
14
+ formatted_value = if display_value.is_a?(DateTime) || display_value.is_a?(Time)
15
+ display_value.strftime("%B %-d, %Y - %H:%M")
16
+ elsif display_value.is_a?(Date)
17
+ display_value.strftime("%B %-d, %Y")
14
18
  else
15
- value
19
+ display_value
16
20
  end
17
21
  %>
18
22
 
@@ -4,6 +4,7 @@
4
4
 
5
5
  # Form field options
6
6
  required ||= false
7
+ combobox = local_assigns[:combobox] || false
7
8
 
8
9
  # Options should be:
9
10
  # - For select: options_for_select array or collection_select params
@@ -21,10 +22,20 @@
21
22
 
22
23
  # Add any additional HTML attributes
23
24
  field_options[:onchange] = local_assigns[:onchange] if local_assigns[:onchange]
25
+ field_options[:list] = "#{field}_datalist_#{setup[:form_object].object.object_id}" if combobox
24
26
  %>
25
27
 
26
28
  <%= setup[:form_object].label field, setup[:field_label] %>
27
- <% if collection_select_params %>
29
+ <% if combobox %>
30
+ <%= setup[:form_object].text_field field, field_options %>
31
+ <datalist id="<%= field_options[:list] %>">
32
+ <% options.each do |option| %>
33
+ <% value = option.is_a?(Array) ? option.last : option %>
34
+ <% text = option.is_a?(Array) ? option.first : option %>
35
+ <option value="<%= value %>"><%= text %></option>
36
+ <% end %>
37
+ </datalist>
38
+ <% elsif collection_select_params %>
28
39
  <%= setup[:form_object].collection_select(
29
40
  field,
30
41
  collection_select_params[:collection],
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chobble-forms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chobble.com
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-10-13 00:00:00.000000000 Z
11
+ date: 2025-10-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails