2020-05-22 14:21:54 +03:00
|
|
|
## What is Vue Formulario?
|
|
|
|
|
2021-06-13 00:30:19 +03:00
|
|
|
Vue Formulario is a library, inspired by <a href="https://vueformulate.com">Vue Formulate</a>, that handles the core logic
|
2020-11-10 10:24:31 +03:00
|
|
|
for working with forms and gives full control on the form presentation.
|
2020-05-22 14:21:54 +03:00
|
|
|
|
|
|
|
## Examples
|
|
|
|
|
2021-05-22 16:50:53 +03:00
|
|
|
Every form control have to rendered inside FormularioField component. This component provides `id` and `context` in
|
2020-11-10 10:24:31 +03:00
|
|
|
v-slot props. Control should use `context.model` as v-model and `context.runValidation` as handler for `blur` event
|
|
|
|
(it is necessary for validation when property `validationBehavior` is `demand`). Errors list for a field can be
|
|
|
|
accessed through `context.allErrors`.
|
2020-05-22 14:21:54 +03:00
|
|
|
|
2020-05-22 14:35:52 +03:00
|
|
|
The example below creates the authorization form from data:
|
2020-05-22 14:21:54 +03:00
|
|
|
```json
|
2020-11-10 10:24:31 +03:00
|
|
|
{
|
|
|
|
"username": "",
|
|
|
|
"password": "",
|
|
|
|
"options": {
|
|
|
|
"anonymous": false,
|
|
|
|
"tags": ["test"]
|
2020-05-22 14:21:54 +03:00
|
|
|
}
|
2020-11-10 10:24:31 +03:00
|
|
|
}
|
2020-05-22 14:21:54 +03:00
|
|
|
```
|
|
|
|
|
|
|
|
```html
|
2020-11-10 10:24:31 +03:00
|
|
|
<FormularioForm
|
|
|
|
v-model="formData"
|
|
|
|
name="formName"
|
|
|
|
>
|
2021-05-22 16:50:53 +03:00
|
|
|
<FormularioField
|
2020-11-10 10:24:31 +03:00
|
|
|
v-slot="{ context }"
|
|
|
|
name="username"
|
|
|
|
validation="required|email"
|
|
|
|
validation-behavior="live"
|
2020-05-22 14:21:54 +03:00
|
|
|
>
|
2020-11-10 10:24:31 +03:00
|
|
|
<input
|
|
|
|
v-model="context.model"
|
|
|
|
type="text"
|
|
|
|
@blur="context.runValidation"
|
2020-05-22 14:21:54 +03:00
|
|
|
>
|
2020-11-10 10:24:31 +03:00
|
|
|
<div v-if="context.allErrors.length > 0">
|
|
|
|
<span
|
|
|
|
v-for="(error, index) in context.allErrors"
|
|
|
|
:key="index"
|
2020-05-22 14:21:54 +03:00
|
|
|
>
|
2020-11-10 10:24:31 +03:00
|
|
|
{{ error }}
|
|
|
|
</span>
|
|
|
|
</div>
|
2021-05-22 16:50:53 +03:00
|
|
|
</FormularioField>
|
2020-05-22 14:21:54 +03:00
|
|
|
|
2021-05-22 16:50:53 +03:00
|
|
|
<FormularioField
|
2020-11-10 10:24:31 +03:00
|
|
|
v-slot="{ context }"
|
|
|
|
name="password"
|
|
|
|
validation="required|min:4,length"
|
|
|
|
>
|
|
|
|
<input
|
|
|
|
v-model="context.model"
|
|
|
|
type="password"
|
2020-05-22 14:21:54 +03:00
|
|
|
>
|
2021-05-22 16:50:53 +03:00
|
|
|
</FormularioField>
|
2020-05-22 14:21:54 +03:00
|
|
|
|
2021-05-22 16:50:53 +03:00
|
|
|
<FormularioFieldGroup name="options">
|
|
|
|
<FormularioField
|
2020-11-10 10:24:31 +03:00
|
|
|
v-slot="{ context }"
|
|
|
|
name="anonymous"
|
2020-05-22 14:21:54 +03:00
|
|
|
>
|
2020-11-10 10:24:31 +03:00
|
|
|
<div>
|
|
|
|
<input
|
|
|
|
id="options-anonymous"
|
|
|
|
v-model="context.model"
|
|
|
|
type="checkbox"
|
|
|
|
>
|
|
|
|
<label for="options-anonymous">As anonymous</label>
|
|
|
|
</div>
|
2021-05-22 16:50:53 +03:00
|
|
|
</FormularioField>
|
|
|
|
</FormularioFieldGroup>
|
2020-11-10 10:24:31 +03:00
|
|
|
|
2021-05-22 16:50:53 +03:00
|
|
|
<FormularioField
|
2020-11-10 10:24:31 +03:00
|
|
|
v-slot="{ context }"
|
|
|
|
name="options.tags[0]"
|
|
|
|
>
|
|
|
|
<input
|
|
|
|
v-model="context.model"
|
|
|
|
type="text"
|
|
|
|
>
|
2021-05-22 16:50:53 +03:00
|
|
|
</FormularioField>
|
2020-11-10 10:24:31 +03:00
|
|
|
</FormularioForm>
|
2020-05-22 14:21:54 +03:00
|
|
|
```
|
2020-05-17 18:21:04 +03:00
|
|
|
|
|
|
|
## License
|
|
|
|
|
|
|
|
[MIT](https://opensource.org/licenses/MIT)
|
|
|
|
|
2020-05-22 14:37:44 +03:00
|
|
|
Copyright (c) 2020-present, [RetailDriver LLC](https://www.retailcrm.pro) <br>
|
2020-05-22 14:35:52 +03:00
|
|
|
Copyright (c) 2020-present, [Braid LLC](https://www.wearebraid.com/)
|