-
-
Notifications
You must be signed in to change notification settings - Fork 732
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom select #1091
Custom select #1091
Conversation
This is consistent with checkboxes, radiobuttons and many other fields.
…et Bootstrap4 custom-control It also updates the documentation on File widget: the clearable file widget in recent django-crispy-forms looks similar to the non-clearable custom widget.
Codecov Report
@@ Coverage Diff @@
## master #1091 +/- ##
==========================================
+ Coverage 97.20% 97.22% +0.01%
==========================================
Files 24 24
Lines 2791 2811 +20
Branches 243 243
==========================================
+ Hits 2713 2733 +20
Misses 38 38
Partials 40 40
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
…eld.py to templates code
With the latest commit (12th Dec): the logic to fix this is in the templates. This has a problem: the custom-select But this case is not working yet: But since this is related to any widget I would plan a solution in #1093 |
@@ -159,23 +165,17 @@ All previous, ``bootstrap`` (version 2 and 3) attributes are also settable in bo | |||
.. |customfile| image:: images/custom_file_field.png | |||
:width: 300px | |||
:align: middle | |||
.. |clearablefile| image:: images/clearable_file.png |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dropping clearable file from here is an unrelated change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Edit: oh wait, in any case it intended to drop the file field custom clearable that I had intended to drop since it looks the same as the file field custom. I'll build the docs and see that all looks good and take new screenshots if needed.
Previous message:
Yes (I noted this in the commit, perhaps I should move it to a PR): cpina@c134023
The file field custom clearable png is, at the moment, broken in the documentation: https://django-crispy-forms.readthedocs.io/en/latest/form_helper.html?bootstrap-4-helper-attributes#bootstrap-4-helper-attributes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dropping clearable file from here is an unrelated change?
I've created a branch minimising this change: https://github.com/cpina/django-crispy-forms/tree/custom-select-with-minimal-docs-change . I might have got a bit carried on the other day. I can make the other changes (delete the clearable one maybe, re-order the table so it matches the text) in another PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The clearable file also looks awful on rtd, I'm not sure it's that helpful.
:width: 300px | ||
:align: middle | ||
.. |customradio| image:: images/custom_radio.png | ||
.. |customselect| image:: images/custom_select.png |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/home/pi/Projects/django-crispy-forms/docs/form_helper.rst:156: WARNING: image file not readable: images/select.png
/home/pi/Projects/django-crispy-forms/docs/form_helper.rst:159: WARNING: image file not readable: images/custom_select.png
I can't seem to build the docs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll amend this (I missed adding some files). How are you building the docs? I can't see in the documentation or in the .github action.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cd docs
make html
I might add this in the docs (or read them better if it's there)
Hi Carles, thanks for looking at this, this is a nice improvement. I've left a few small comments. I think we should take this as a standalone item which covers the most likely use case. We can then look at a select within a append / prepended wrapper as a separate item? I'd be happy to push a release with just this change. |
Previously it was only to single selects.
I'm also happy to address the pre/post append select issues as part of #1093 . I think that pre/post append might need bigger changes and longer discussion. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me! 🎉
Add
class="custom-control custom-select"
for the select widgets.Before (see the arrow at the end):
After (Bootstrap4 arrow):
When it has been seen it cannot be unseen!
In django-crispy-forms Bootstrap4 there is no specific template for the select widget: it relies on the Django template. This is good (one less think to maintain) but conceptually I think that would prefer to avoid having Bootstrap4/template-pack specific code in
crispy_forms_field.py
: "custom-control custom-select" could be moved into a new template for "select" like it's done for other widgets. On the other hand it's handy to not have the template and piiggyback Django select (django/forms/templates/django/forms/widgets/select.html
) (other possible refactorings would be possible). Perhaps when working on Bootstrap5 it would be a good moment to re-consider this.The Bootstrap4 (or Bootstrap3) code in
crispy_forms_field.py
dates from 2013.