django-bootstrap5 icon indicating copy to clipboard operation
django-bootstrap5 copied to clipboard

Form input group class mistake

Open Kanezal opened this issue 2 years ago • 3 comments

In renders.py there is a function called make_input_group that adds addon_before_class or addon_after_class . But it creates a group form that looks like this:

<div class="input-group">
	<div class="input-group-prepend">
		<span class="input-group-text">Some label</span>
	</div>
	<select name="some" class="form-select" title="" required="" id="id_some">
		<option value="" selected="">---------</option>
		<option value="1">Some option</option>
	</select>
</div>

So this html looks like this: image But in Boostrap5 group form docs there is nothing about class input-group-prepend. Because it was dropped: image

So html should look like this:

<div class="input-group">
	<span class="input-group-text">Some label</span>
	<select name="some" class="form-select" title="" required="" id="id_some">
		<option value="" selected="">---------</option>
		<option value="1">Some option</option>
	</select>
</div>

And it should look like this: image

I have pretty easy method to solve it by rewrite a make_input_group and a make_input_group_addon functions:

def make_input_group_addon(self, content):
    if not content:
        return ""
    content = '<span class="input-group-text">{content}</span>'.format(content=content)
    return content

def make_input_group(self, html):
    if self.is_input_group:
        before = self.make_input_group_addon(self.addon_before)
        after = self.make_input_group_addon(self.addon_after)
        html = self.append_errors("{before}{html}{after}".format(before=before, html=html, after=after))
        html = '<div class="input-group">{html}</div>'.format(html=html)
    return html

Please add this in django-bootstrap5

Kanezal avatar Jun 03 '22 18:06 Kanezal