docs: Fixed README.md
This commit is contained in:
parent
076e140452
commit
13390b59c4
52
README.md
52
README.md
@ -1,86 +1,90 @@
|
|||||||
## What is Vue Formulario?
|
## What is Vue Formulario?
|
||||||
|
|
||||||
Vue Formulario is a library, based on <a href="https://vueformulate.com">Vue Formulate</a>, that handles the core logic for working with forms and gives full control on the form presentation.
|
Vue Formulario is a library, based on <a href="https://vueformulate.com">Vue Formulate</a>, that handles the core logic
|
||||||
|
for working with forms and gives full control on the form presentation.
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
Every form control have to rendered inside FormularioInput component. This component provides `id` and `context` in v-slot props. Control should use `context.model` as v-model and `context.blurHandler` as handler for `blur` event (it is necessary for validation when property `errorBehavior` is `blur`). Errors object list for field can be accessed through `context.allErrors`. Each error is an object with fields message (translated message), rule (rule name) and context.
|
Every form control have to rendered inside FormularioInput component. This component provides `id` and `context` in
|
||||||
|
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`.
|
||||||
|
|
||||||
The example below creates the authorization form from data:
|
The example below creates the authorization form from data:
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"username": "",
|
"username": "",
|
||||||
"password": "",
|
"password": "",
|
||||||
"options": {
|
"options": {
|
||||||
"anonym": false,
|
"anonymous": false,
|
||||||
"tags": ["test"]
|
"tags": ["test"]
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<FormularioForm
|
<FormularioForm
|
||||||
v-model="formData"
|
v-model="formData"
|
||||||
name="formName"
|
name="formName"
|
||||||
>
|
>
|
||||||
<FormularioInput
|
<FormularioInput
|
||||||
v-slot="vSlot"
|
v-slot="{ context }"
|
||||||
name="username"
|
name="username"
|
||||||
validation="required|email"
|
validation="required|email"
|
||||||
error-behavior="live"
|
validation-behavior="live"
|
||||||
>
|
>
|
||||||
<input
|
<input
|
||||||
v-model="vSlot.context.model"
|
v-model="context.model"
|
||||||
type="text"
|
type="text"
|
||||||
@blur="vSlot.context.blurHandler"
|
@blur="context.runValidation"
|
||||||
>
|
>
|
||||||
<div v-if="vSlot.context.showValidationErrors">
|
<div v-if="context.allErrors.length > 0">
|
||||||
<span
|
<span
|
||||||
v-for="(error, index) in vSlot.context.allErrors"
|
v-for="(error, index) in context.allErrors"
|
||||||
:key="index"
|
:key="index"
|
||||||
>
|
>
|
||||||
{{ error.message }}
|
{{ error }}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</FormularioInput>
|
</FormularioInput>
|
||||||
|
|
||||||
<FormularioInput
|
<FormularioInput
|
||||||
v-slot="vSlot"
|
v-slot="{ context }"
|
||||||
name="password"
|
name="password"
|
||||||
validation="required|min:4,length"
|
validation="required|min:4,length"
|
||||||
>
|
>
|
||||||
<input
|
<input
|
||||||
v-model="vSlot.context.model"
|
v-model="context.model"
|
||||||
type="password"
|
type="password"
|
||||||
>
|
>
|
||||||
</FormularioInput>
|
</FormularioInput>
|
||||||
|
|
||||||
<FormularioGrouping name="options">
|
<FormularioGrouping name="options">
|
||||||
<FormularioInput
|
<FormularioInput
|
||||||
v-slot="vSlot"
|
v-slot="{ context }"
|
||||||
name="anonym"
|
name="anonymous"
|
||||||
>
|
>
|
||||||
<div>
|
<div>
|
||||||
<input
|
<input
|
||||||
:id="vSlot.id"
|
id="options-anonymous"
|
||||||
v-model="vSlot.context.model"
|
v-model="context.model"
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
>
|
>
|
||||||
<label :for="vSlot.id">As anonym</label>
|
<label for="options-anonymous">As anonymous</label>
|
||||||
</div>
|
</div>
|
||||||
</FormularioInput>
|
</FormularioInput>
|
||||||
</FormularioGrouping>
|
</FormularioGrouping>
|
||||||
|
|
||||||
<FormularioInput
|
<FormularioInput
|
||||||
v-slot="vSlot"
|
v-slot="{ context }"
|
||||||
name="options.tags[0]"
|
name="options.tags[0]"
|
||||||
>
|
>
|
||||||
<input
|
<input
|
||||||
v-model="vSlot.context.model"
|
v-model="context.model"
|
||||||
type="text"
|
type="text"
|
||||||
>
|
>
|
||||||
</FormularioInput>
|
</FormularioInput>
|
||||||
</FormularioForm>
|
</FormularioForm>
|
||||||
```
|
```
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
Loading…
Reference in New Issue
Block a user