1.0.3 • Published 5 years ago

@laragle/form v1.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
5 years ago

form

Vue form wrapper.

Installation

npm install @laragle/form

Usage

<template>
  <div>
    <h3>Login</h3>
    <input type="email" v-model="form.email" />
    <div class="error" v-if="form.errors.has('email')">{{ form.errors.get('email') }}</div>
    <input type="password" v-model="form.password" />
    <div class="error" v-if="form.errors.has('password')">{{ form.errors.get('password') }}</div>
    <button @click="login" >Login</button>
  </div>
</template>

<script>
  import axios from 'axios';
  import form from '@laragle/form';
  
  export default {
    data() {
      return {
        form: new Form({
          email: '',
          password: ''
        })
      }
    },
    methods: {
      login() {
        this.form.errors.clear();
        axios.post('/login', this.form.payload())
             .then(({ data }) => {
                this.form.reset();
             })
             .catch((error) => {
                this.form.errors.record(error);
             })
      }
    }
  }
</script>
1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago