Skip to content

Commit

Permalink
Added checked option to check box form helper.
Browse files Browse the repository at this point in the history
  • Loading branch information
UweKubosch committed Mar 13, 2024
1 parent 46c4606 commit 2f6f05f
Show file tree
Hide file tree
Showing 2 changed files with 10 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 '0.13.6'
version '0.14.0'
final String JRUBY_VERSION = '9.4.5.0';

repositories {
Expand Down
14 changes: 9 additions & 5 deletions src/main/resources/ruby/form_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,16 @@ def checkbox(object, field_name, **opts)
disabled = opts.delete(:disabled)

checked =
if object[field_name].nil?
false
elsif field_name =~ /\[.*\]/ && value
object[field_name].split(',').include?(value.to_s)
if opts.key?(:checked)
opts.delete(:checked)
else
object[field_name] == "true"
if object&.[](field_name).nil?
false
elsif field_name =~ /\[.*\]/ && value
object[field_name].split(',').include?(value.to_s)
else
object[field_name] == "true"
end
end
html = +''
unless no_hidden
Expand Down

0 comments on commit 2f6f05f

Please sign in to comment.