Skip to content

Commit

Permalink
Add wrapper and label class to the bootstrap_textarea method
Browse files Browse the repository at this point in the history
  • Loading branch information
UweKubosch committed Dec 6, 2024
1 parent 9d348aa commit 5e32f6c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 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.7'
version '1.0.8'
final String JRUBY_VERSION = '9.4.8.0';

repositories {
Expand Down
13 changes: 11 additions & 2 deletions src/main/resources/ruby/form_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ def hidden_input(object, field_name, **opts)

def textarea(object, field_name, **opts)
hide_label = opts.delete(:hide_label) || opts.delete(:no_label)
label_class = opts.delete(:label_class)
label_style = opts.delete(:label_style)
label_key = label_key_opt(opts, field_name)
label_suffix = opts.delete(:hide_label_suffix) ? nil : ':'
Expand All @@ -230,7 +231,7 @@ def textarea(object, field_name, **opts)
if hide_label
html = +""
else
html = +%{<label for="#{field_name}" style="#{label_style}">#{CGI.escapeHTML(label)}</label> }
html = +%{<label for="#{field_name}" class="#{label_class}" style="#{label_style}">#{CGI.escapeHTML(label)}</label> }
end

html << '<span>' if appendix
Expand All @@ -249,8 +250,16 @@ def textarea(object, field_name, **opts)
end

def bootstrap_textarea(object, field_name, **opts)
wrapper_class = opts.key?(:wrapper_class) ? opts.delete(:wrapper_class) : WRAPPER_CLASS
label_class = opts.delete(:label_class) || 'form-label'
classes = field_classes(object, field_name, opts.delete(:class))
textarea(object, field_name, hide_label_suffix: true, class: classes, no_break: true, **opts)
html = textarea(object, field_name, hide_label_suffix: true, class: classes, no_break: true, label_class:, **opts)
if wrapper_class.present?
html = <<~HTML
<div class="#{wrapper_class}">#{html}</div>
HTML
end
html
end

private def object_field_value(object, field_name)
Expand Down

0 comments on commit 5e32f6c

Please sign in to comment.