-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
fix(forms): BS4.beta form/input validation styles & components #847
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add browser validation support
form-fieldset is now an alias of form-group
@pi0 @alexsasharegan and @mosinve Could you guys go over the changes? |
Codecov Report
@@ Coverage Diff @@
## 1.x #847 +/- ##
==========================================
+ Coverage 41.31% 41.86% +0.55%
==========================================
Files 84 85 +1
Lines 2326 2343 +17
Branches 659 670 +11
==========================================
+ Hits 961 981 +20
+ Misses 1216 1213 -3
Partials 149 149
Continue to review full report at Codecov.
|
…strap-vue into tmorehouse-validation
…strap-vue into tmorehouse-validation
…strap-vue into tmorehouse-validation
alexsasharegan
approved these changes
Aug 16, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Support for the new validation styles and states, and new/changed/removed components.
Components
New functional components:
<b-form-text>
help text block<b-form-feedback>
only shown when validation fails! orstate="invalid"
, as must be a sibling at the same level as the input and follow after the input<b-form-row>
for creating tighterrows
with tighter margins inside formsNew components:
<b-form-textarea>
Dedicated component for text area, with additional featuresBreaking change components:
<b-form-input>
Removed textarea support.static
prop is nowplaintext
and renders an input with new stylesRenamed components:
<b-form-fieldset>
is now<b-form-group>
(although<b-form-fieldset>
is available as an alias ofform-group
)Removed Components:
<b-form-static>
removed in favor of newplaintext
prop on<bform-input>
and<b-form-textarea>
Validation states:
the
state
props now accepts one of three values:'valid'
(green color),'invalid'
(red color), ornull
(default text color)The new
<b-form-feedback>
component (used in the<form-group>
component is only shown when validation isinvalid
state. It is not shown forvalid
states! (BS4 change in behavior)Validation can be performed one of three ways.
Two methods involve using browser HTML5 validation. Inputs must be wrapped in an element that has the class
was-validated
(such asb-form
andb-form-group
which have thevalidated
prop set (which adds thewas validated
class to the wrapper (<b-form-radio>
also supports thevalidated
prop).There are two ways to e control this feature. One is to use a
b-form
wrapper withnovalidate
not set. The form components will immediately be validated (and display browser native error messages). The second option is to setnovalidate
and then trap on submit and run the browser nativeform.checkValidity()
method and then setvalidated
prop on<b-form>
.<b-form>
will emit the nativeform submit
event.The 3rd option (and probably the preferred method for Vue) is what BS4 calls server side validation, but it can be run on client. it applies
is-valid
oris-invalid
to the inputs via thestate
prop (set tovalid
orinvalid
) which will trigger contextual styles on the form controls. any<b-form-feedback>
element taht is a sibling on the invalid control will be shown.