Open lemonsaurus opened 5 years ago
It works pretty much how you'd expect.
class SetupForm(Form):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.helper = FormHelper(self)
self.helper.layout = Layout(
IconField("username", icon_prepend="user", title="Username"),
IconField("email", icon_prepend="at", title="Email"),
IconField("password", icon_prepend="key", title="Password"),
IconField("confirm_password", icon_prepend="key", title="Password (Again)"),
Submit("submit", "Submit", css_class="is-fullwidth")
)
The only problem is that this field doesn't render error text like the regular input does:
Here's what the normal input does if you have errors:
I've been looking into how to fix this, but I haven't figured it out yet.
Oh, and it also doesn't support placeholders, but that's a quick fix. I'm not entirely sure if anything does, though.
It looks like there's already a feature in this fork for an input field with icons prepended or appended.
This is a useful feature, so we need to figure out how it works and then document it in our readme.
I think it's probably supposed to be a CrispyForms Layout object, so inside the
__init__
of the forms.Form object you'd add aLayout(InputFieldWithIcons(...))
or something like that, but I haven't gotten it working yet.