bootstrap_form
bootstrap_form copied to clipboard
[v4] input_group_content method needs fixing
PR #367 wasn't ready to be merged.
def input_group_content(content)
return content if content.match(/btn/)
content_tag(:span, content, class: 'input-group-text')
end
content.match is there to sniff if content possibly has <button class="btn">, I'm guessing. If your string has "btn" it won't render right. Or you have some html without btn classes... (No test case for this in PR either)
I think better solution is to introduce :append_text and :prepend_text that will do span wrapping. Otherwise it's up to the user to provide content with proper classes.
@desheikh thoughts on this one? I agree match(/btn/) seems like a very blunt instrument.
I think the intent of PR #367 was good, but I agree with the others that matching on /btn/ doesn't meet the intent.
To get the Bootstrap 4 alpha out the door, I suggest we remove the check for /btn/ and simply document that the user needs to manually wrap text. Once we get alpha out, I think the suggestion at https://github.com/bootstrap-ruby/bootstrap_form/issues/396#issue-290116077 is good.
I'd be happy to update the README. Does anyone want to fix the code @GBH @desheikh ? We're close to being ready for an alpha release, I think, so it would be nice if we can fix this soon.
I fixed by changing API like so:
f.text_field :foo, append: "Text"
f.text_field :foo, append: { html: "<button>Submit</button>".html_safe }
By default it will wrap text in the input-group-text. If it's sent in as a hash, it doesn't wrap it.