-
Notifications
You must be signed in to change notification settings - Fork 162
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
Validation messages do not display correctly with Bootstrap 4 #431
Comments
One major change in Bootstrap 4 is moving to flexbox and dropping .form-horizontal which didn't affect Deform, since none of the vertical or horizontal alignments is used in current Deform templates. Any of the pull requests #25, #187, #282, #216 to add horizontal support would have broken Deform after the upgrade to Bootstrap 4 and needed substantial amount of time and effort to fix them. we best remove any of alignment options from milestone we added couple of months ago, and close all open requests for horiazontal support and suggest overriding templates as instructed here. We could set up a separate repository for additional templates that developers could share their tamplates instead of changing code to provide new alignment options. Regarding the validation messages, it is not clear how and where error_class = "error", is used. |
I agree with all that. Deform provides a basic set of templates that can be overridden. I like the idea of sharing customized Deform templates, maybe Regarding |
I can confirm that beautify.css is not referenced in any of the widget requirements or in default_resources. Let's start by removing beautify.css, and cleaning up TODO Then closing the issues related to horizontal support and suggesting overriding the template instead, then cleaning TODO and adding template repository in TODO. You are right about none existant "error" string in either of bootstrap javascript or bootstrap css files. setting error_class = "Some_Random_Words", has no effect and all tests are successfully passed, however I need to have a better understanding of Deform internals before moving forward, specifically knowing how fileld.error is being set, what would be it's value and from where it is being injected to here. these are the only places error_class value is being evaluated. error_class seems to be an outstanding issue #168 at least since 2013, and not when it is set in Widget class but when overriden in MappingWidget or in SequenceWidget |
I removed beautify.css in 366355c. TODOs are there for historical reference only. I wish they never existed and had been put into the issue tracker and other more appropriate places, but Horizontal alignment issues and PRs will remain open for anyone who wants to take them on for the Deform 2.x branches. They will not be used in the 3.x branches. I changed the milestone for these issues and PRs accordingly. I'll look into that |
help-block is dropped in Bootstrap 4 and we need to use form-text and form-text text-danger in case of error instead. this fixes the error text color. @stevepiercy please merge deformdemo and deform latest pull requests. |
@stevepiercy with current configuration Deform latest pull request needs to be pushed to pip repository to be able to run the Deformdemo test successfully and then run the functional test on Deform. This problem of interdependency will be solved, If we create a branch in Deform that hold latest merge before merging to master, then update the Deformdemo .travis.yml to pip install from Deform branch that hold one to the last change. |
Looking over this again, and I realized a few things. My opening comment has too many mistakes and overlooked a lot of stuff. This comment supersedes it. We need to adapt to the server-side rendering advice of forms for both help text and validation, specifically server-side validation classes in Bootstrap 4. In Deform 2.x:
<div
class="form-group has-error item-text"
title="Enter some text"
id="item-deformField1">
<label
for="deformField1"
class="control-label required"
id="req-deformField1">Text</label>
<input
type="text"
name="text"
value=""
id="deformField1"
class=" form-control "/>
<p class="help-block" id="error-deformField1">Required</p>
<p class="help-block" >Enter some text</p>
</div> In Bootstrap 4:
This makes more work to update all the templates and functional tests, but I think it is better to comply with Bootstrap 4 because:
Example of help text/description only<label for="inputPassword">Password</label>
<input type="password" id="inputPassword" class="form-control" aria-describedby="passwordHelpBlock">
<small id="passwordHelpBlock" class="form-text text-muted">
Your password must be 8-20 characters long, contain letters and numbers, and must not contain spaces, special characters, or emoji.
</small> Example of server-side validation error only<label for="inputPassword">Password</label>
<input type="text" class="form-control is-invalid" id="inputPassword" aria-describedby="inputPasswordFeedback" required>
<div id="inputPasswordFeedback" class="invalid-feedback">
You entered only 7 characters, but at least 8 are required.
</div> Example of server-side validation error style with description<label for="inputPassword">Password</label>
<input type="text" class="form-control is-invalid" id="inputPassword" aria-describedby="inputPasswordFeedback" required>
<div id="inputPasswordFeedback" class="invalid-feedback">
You entered only 7 characters, but at least 8 are required.
</div>
<small id="passwordHelpBlock" class="form-text text-danger">
Your password must be 8-20 characters long, contain letters and numbers, and must not contain spaces, special characters, or emoji.
</small> @sydoluciani I'd like your thoughts on this before we do more work. |
@stevepiercy I think we best continue fixing issues gradually and with minimal changes to adapt to Bootstrap 4 and closing outstanding issues or pull requests. there are some structural changes needs to be done and we should consider current bugs and issues before changing the structure of the templates, this way we can discuss and then change the logic as well as the structure as we go. For example, my latest pull request, fixes only error messages that was using help-block, and after merge we can close pull request 354 On next pull request we should be able to close #168 Then we upgrade the bootstrap to version 4.5 and closing #432 Then we upgrade select2 , closing issue #433 On every pull request, as we change Deform code, we need to change the functional tests to pass the test and gradually replace all those findid functions with ActionChains if we get error. |
I was not able to point Deformdemo's Deform installation in setup.py to different branch in github, but we can create a deform_3_dev branch and merge new pull requests to deform_3_dev branch and finally merge the deform_3_dev branch to master branch when happy with overal changes, this way we can try pointing Deformdemo to deform_3_dev branch to break the interdependency loop and make the process easier, instead of pushing every pull request to pip repository. |
We can create deformdemo_3_dev branch, that is pointing to deform_3_dev instead of using pip repository, and merge these to master branch when happy with overal pull request changes merged to dev branch. It can't be one big change, and definitely there will be issues or bugs that is going to deviate any plan to change template structure, so it is best to make small changes and go forward. |
We have |
Also I agree that small incremental changes are better than one huge change. It helps to have a big picture of the huge change, broken down into the small changes. We have a 3.0 milestone that can serve as the big picture, and each issue can be a small change for what we have discussed so far. That will also help focus discussion. I'll create smaller issues out of what we have discussed here. |
It is a good idea to have a separate branch for version 2 of Deform and Deformdemo. for the sake of comparison tried version 2 of Deform couple of days back, and noticed selenium still is pointing to old version in setup.py and got warnnings and errors on isort module, so gave up on it. I can start new pull requests for each fix, then we can discuss about each change, and if it is approved, then it is up to you if you want to merge it to master or latest. I would like to spend couple of hours a day on Deform and Deformdemo until fully understand all bits and pieces of Deform then only spend couple of hours a week to support Deform. |
I did a little work on the Deform Those tests were fixed in Deform |
I did some work to get functional tests to pass on Deform Anyway, both repos should now be in a good state for future development, running all builds successfully. I still need to break out new branches for deformdemo. |
After I break out deformdemo into |
@stevepiercy Thank you. |
Yeah, that's another item we need to do. Pylons infrastructure team have a private repo that automatically deploys https://deformdemo.pylonsproject.org/. I think we need to have two sites and a redirect:
I'll chat with the infra team about this. |
I forgot we already have https://github.com/Pylons/deformdemo/tree/2.0-branch, but it was old and had drifted. I have updated it and pushed it. I have a couple more changes to make, but at least that branch is now present and usable on GitHub. It now pulls in the Deform I also have to finish updating Deform I'll try to finish these items later today. |
All right! Deform 2.0.11 is out the door, and is synched with deformdemo 2.0.11. I still need to update the deployment of https://deformdemo.pylonsproject.org/ but I can do that later. Now I can start working on the backlog of recent PRs. |
@stevepiercy with the latest merge, we fixed textinput, mapping and sequece widgets but I just noticed select2 and select fields still not reflecting fields with the error in different color. I will look in to it some time next week then we can close this issue. |
@stevepiercy Thank you. |
@sydoluciani I broke out the issues we know of into a both a new label BS4 and the 3.0.0 milestone. I think this issue can now be closed, unless I missed anything. |
Bootstrap 4 made changes to the validation messages from Bootstrap 3. The migration guide notes:
For Deform this means:
error_class
fromerror
toinvalid-feedback
.is-invalid
to the HTML input. Note that both this and the previous must be done jointly in order for the error message to appear.has-error
withis-invalid
.<p class="help-block"
with<div class="form-text invalid-feedback"
as well as the closing tag. See https://getbootstrap.com/docs/4.5/components/forms/#help-textExamples
deform/templates/mapping_item.pt
deform/templates/textinput.pt
See also https://getbootstrap.com/docs/4.5/components/forms/?#validation, and in particular https://getbootstrap.com/docs/4.5/components/forms/?#server-side
The text was updated successfully, but these errors were encountered: