Skip to content

Commit

Permalink
Allow selecting nil for select_field.
Browse files Browse the repository at this point in the history
Rename `select_input` to `select_field` but keep the alias.
Rename `bootstrap_select_input` to `bootstrap_select`, but keep the alias.
  • Loading branch information
UweKubosch committed Dec 3, 2024
1 parent 3aa9db0 commit 02fd784
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {
}

group 'no.datek'
version '1.0.5'
version '1.0.6'
final String JRUBY_VERSION = '9.4.8.0';

repositories {
Expand Down
13 changes: 8 additions & 5 deletions src/main/resources/ruby/form_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ def bootstrap_textarea(object, field_name, **opts)
(object.respond_to?(:[]) ? object[field_name.to_sym] : object.send(field_name)).to_s.strip
end

def select_input(object, field_name, option_map = [], **opts)
def select_field(object, field_name, option_map = [], **opts)
id_name = opts.delete(:id) || field_name
no_break = opts.delete(:no_break) || opts.delete(:inline)
prompt = opts.delete(:prompt)
Expand All @@ -265,7 +265,7 @@ def select_input(object, field_name, option_map = [], **opts)
disabled = opts.delete(:disabled)
multiple = opts.delete(:multiple)
ondblclick = opts.delete(:ondblclick)
selected = opts.delete(:selected)
selected = opts.delete(:selected) || '' if opts.key?(:selected)

uses_select2 = opts[:class] =~ /chosen-select|select2/

Expand Down Expand Up @@ -315,9 +315,9 @@ def select_input(object, field_name, option_map = [], **opts)
html
end

alias select_field select_input
alias select_input select_field

def bootstrap_select_input(object, field_name, option_map = [], **opts, &block)
def bootstrap_select(object, field_name, option_map = [], **opts, &block)
opts[:id] ||= field_name
classes = select_classes(object, field_name, opts.delete(:class))
hide_label = opts.delete(:hide_label) || opts.delete(:no_label)
Expand All @@ -337,7 +337,7 @@ def bootstrap_select_input(object, field_name, option_map = [], **opts, &block)
end

html << %{<div class="input-group flex-nowrap" >} if append
html << select_input(object, field_name, option_map, class: classes, no_break: true, **opts, &block)
html << select_field(object, field_name, option_map, class: classes, no_break: true, **opts, &block)
if append
[*append].compact.each do |addon|
if addon.start_with?('<')
Expand All @@ -356,6 +356,9 @@ def bootstrap_select_input(object, field_name, option_map = [], **opts, &block)
html
end

alias bootstrap_select_field bootstrap_select
alias bootstrap_select_input bootstrap_select

# Will only work with Bootstrap
def datetime_input(object, field_name, **opts)
hide_label = opts.delete(:hide_label) || opts.delete(:no_label)
Expand Down

0 comments on commit 02fd784

Please sign in to comment.