Giter VIP home page Giter VIP logo

laravel-form-validation's Introduction

नमस्ते

Imagine some fancy stats and badges here

laravel-form-validation's People

Contributors

ankurk91 avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

laravel-form-validation's Issues

[idea] Form data within From class object

v-invalid directive is not reactive in bootstrap-vue modal

<template>
  <b-modal id="create-page-modal" title="Add new page"
           @hidden="resetModal"
           @ok="handleOk">
    
    <div class="form-group required">
      <label>Sequence</label>
      <input type="number" 
             class="form-control" 
             name="sequence"
             v-model="page.sequence"
             v-invalid="form.$errors">
      <field-error :bag="form.$errors" field="sequence"/>
    </div>

    <template v-slot:modal-footer="{ ok, cancel }">
      <button class="btn btn-secondary" @click="cancel()">
        Cancel
      </button>
      <button class="btn btn-primary" :disabled="form.$pending" @click="ok()">
        <span v-if="form.$pending">{{ form.$progress }}% Saving...</span>
        <span v-else>
          <i class="fas fa-check-circle"/> Save
        </span>
      </button>
    </template>
  </b-modal>
</template>
<script>
  import Form from 'laravel-form-validation'

  export default {
    name: 'CreatePageModal',
    props: {
      documentId: {}
    },
    data() {
      return {
        form: new Form(),
        page: {}
      }
    },
    mounted() {
      //
    },
    methods: {
      handleOk(event) {
        event.preventDefault();
        this.submit()
      },
      resetModal() {
        this.form.$errors.clear()
      },
      submit() {
        this.form.post(this.postUrl, this.page)
            .then((response) => {
              this.$emit('saved', response, this.documentId);
              this.$bvModal.hide('create-page-modal')
            })
            .catch((error) => {
              // handle error
              // this.$forceUpdate()
            })
      }
    },
    computed: {
      postUrl() {
        return 'documents/' + this.documentId + '/pages'
      }
    }
  }
</script>

Try to submit the form and let validation error come from server, it wont be shown, the v-invalid directive has an old copy of $errors.

Possible Workaround (ugly):

this.$forceUpdate()

then() response format base on axios is better

Hello @ankurk91

Thank you for your project

I think response on then() use axios format is better and not confused.
promise axios normal format is response.data.xxxx

and now response on catch() is ok

axios({
  method: 'get',
  url: 'http://bit.ly/2mTM3nY',
  responseType: 'stream'
})
  .then(function (response) {
    response.data.xxxx
  });

please consider.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.