Add Object Oriented Forms
to your JavaScript apps:
// Create a Form instance
const form = new Form({
name: '',
description: ''
});
// Submit a form
form.post('/endpoint')
.then(response => alert('done!'))
.catch(e => alert('error'));
// Reset the form data
form.reset();
// Get data
form.data();
// Get errors
erros = form.errors;
// Get error by key-name
form.errors.get('key');
// Record errors
let errors = {};
form.errors.record(errors);
// Clear
form.errors.clear();
// Check if has errors
form.errors.any();
To learn more about, visit Laracasts:
- Learn Vue 2: Step By Step: Object-Oriented Forms: Part 1
- Learn Vue 2: Step By Step: Object-Oriented Forms: Part 2
- Learn Vue 2: Step By Step: Object-Oriented Forms: Part 3
You can find the original source code here: https://github.com/laracasts/Vue-Forms/blob/master/public/js/app.js
Hi !
Im receiving this below error:
✘ http://eslint.org/docs/rules/guard-for-in The body of a for-in should be wrapped in an if statement to filter unwanted properties from the prototype
src/pages/auth/Login.vue:120:5
for (let field in data) {
^
✘ http://eslint.org/docs/rules/guard-for-in The body of a for-in should be wrapped in an if statement to filter unwanted properties from the prototype
src/pages/auth/Login.vue:132:5
for (let property in this.originalData) {
^
✘ http://eslint.org/docs/rules/guard-for-in The body of a for-in should be wrapped in an if statement to filter unwanted properties from the prototype
src/pages/auth/Login.vue:143:5
for (let field in this.originalData) {
^
✘ 3 problems (3 errors, 0 warnings)
Errors:
3 http://eslint.org/docs/rules/guard-for-in
@ ./src/router/paths.js 51:13-46
@ ./src/router/index.js
@ ./src/main.js
@ multi (webpack)-dev-server/client?http://localhost:8080 webpack/hot/dev-server ./src/main.js
How do I fix ?