Hidden
The simplest form field you can imagine. Its role is simply to hold a value without displaying anything.
Usage
A bt-form-hidden
is no different from any other form component. You give it a FormControl
or a v-model
so it has a value:
<bt-form-hidden :control="invisibleControl"></bt-form-hidden>
You can assign it with a default value via the value
prop that will be used if the FormControl
doesn't define one:
<bt-form-hidden :control="invisibleControl" value="defaultValue"></bt-form-hidden>
WARNING
This only works with form controls. If you assign the value via v-moddel
, it will always take priority over value
.
Virtual controls
This component is especially important if you're working with a "real" form and not just a v-model
.
That's because all FormControl
are virtual by default, until a view model is associated with them.
This is discussed in detail in this section that should really read if you're not familiar with the concept.
Here is an example of a login form with a hidden CSRF token.
As you can see the value disappear from the form's value if the hidden control is not present in the view. That's because the FormControl
"csrf"
is virtual if no view model is associated with it. So it doesn't contribute to the value of the form, even if it is part of it.