ferdinandfrank / vue-forms

Set of Vue.js components to submit forms with ajax.
https://ferdinandfrank.github.io/vue-forms/
MIT License
5 stars 0 forks source link

Input type file #6

Closed pieinn closed 6 years ago

pieinn commented 6 years ago

Hi Frank,

What about input type file?

For example to upload avatar image -> validate -> save

enctype="multipart/form-data"

Please advice Thank you

ferdinandfrank commented 6 years ago

Just added a new component to upload images: see FormFileInput. Note: The image will be submitted in base64 format.

Feel free to adapt the component to your needs or even to extend the functionality and to submit a pull request! :)

pieinn commented 6 years ago

I think some mistake in documentation FormFileInput. <form-date-input name="[NAME]"></form-date-input>

<form-data-input name="[NAME]"></form-data-input>- no working <form-file-input name="[NAME]"></form-file-input>- no working

ferdinandfrank commented 6 years ago

Sorry fixed the mistake in the documentation. The correct tag name is form-file-input. Why is it not working? What does it say in your browser's console?

pieinn commented 6 years ago

Firstly form-group not appear. And have following in browser's console: [Vue warn]: Invalid prop: type check failed for prop "rules". Expected Array, got Object.

found in---> at resources/assets/vendor/vue-forms/js/components/inputs/FormInput.vue

at resources/assets/vendor/vue-forms/js/components/AjaxForm.vue
ferdinandfrank commented 6 years ago

That shouldn't be an error on the component, but with the definition of the rules prop on your component instance. As the error says, you are probably passing an object instead of an array as the rules value. So, I guess you are doing something like this:

<form-input name="Name" :rules="{min: 5}"></form-input>

The correct way would be to wrap the rules object within an array, so you can specify multiple rule objects:

<form-input name="Name" :rules="[{min: 5}]"></form-input>

See details here.

pieinn commented 6 years ago

I have corrected. Thank you

But what about form-group not appear?

And please advice how to show error with tooltip?

pieinn commented 6 years ago
2017-11-29 17 39 29

Submit Button in ajax-form not active

When i change {require: true} to the [{require: true}]

My code:

<div id="app">
        <ajax-form class="form" method="POST" action="{{ route('user.profile.update') }}" enctype="multipart/form-data" :clear=true>
            {{ csrf_field() }}
            <icon icon="icon-user"></icon>
            <label>@lang('app.your_name')</label>
            <form-input :rules="[{require: true}, {min: 3}]"
                        type="text"
                        name="name"
                        id="name"
                        value={{ Auth::user()->name }}>
            </form-input>
            <icon icon="icon-user_mail"></icon>
            <label>@lang('app.email_address')</label>
            <form-input :rules="[{email: true}]"
                        type="email"
                        name="email"
                        id="email"
                        value={{ Auth::user()->email }}>
            </form-input>
            <icon icon="icon-phone"></icon>
            <label>@lang('app.mobile')</label>
            <form-input :rules="[{require: true}]"
                    type="text"
                    name="mobile"
                    id="mobile" value={{ Auth::user()->mobile }}>
            </form-input>
            <button type="submit" class="btn btn-primary btn-round btn-lg">
                Submit
                <i class="icon-user_check"></i>
            </button>
        </ajax-form>
    </div>
ferdinandfrank commented 6 years ago
pieinn commented 6 years ago

Thank for as usual detailed reply. I will test now.

Form group does not appear: not rendering.

pieinn commented 6 years ago

Submit Button in ajax-form not active: solved change to required and works!