sethsandaru / vue-form-builder

Super Form Builder built on top of Vue with Drag & Drop functionality, savable-form-schema and easy to maintain/upgrade your form.
http://vue-form-builder.sethphat.com
MIT License
413 stars 129 forks source link

v2.1.1 development #88

Closed sethsandaru closed 3 years ago

sethsandaru commented 3 years ago

Features

Bugs

Dunno, let's see

sethsandaru commented 3 years ago

Server-side validation

In case that you want to check more carefully (absolutely we shouldn't trust 100% the data from the clients), then, Server-side Validation would be a great addition.

Also, with Server-side Validation, you may check the data in some special specific business logic regarding your applications.

How server-side validation should work?

Configuration

How it works

Request

fetch('<API_ENDPOINT', {
    data: {
        formValues: {/** your form values **/}
    }
});

Response if has errors

HTTP Status: 422 (Required)

{
    "field-name": Array<String>, // fieldName is configured in Vue Form Builder, value should be the error message(s)
}

// example error response
{
    "phone": ["Phone must start with +84"],
    "quantity": [
        "Stock doesn't have enough for this item",
        "You can't order more than 10 for this item"
    ]
}

Response if no error

A Response with HTTP Code 200 would be enough.

sethsandaru commented 3 years ago

@abhimanusharma I have a question regarding the Server-side Validation behaviour. Do you think is it a good idea to show a loading screen while the form doing the XHR request? Or it would be better if the form can disable the button after users pressed it?

abhimanusharma commented 3 years ago

@sethsandaru Actually, I use both. I show a loader on the button and make it disable while the response is being retrieving by the XHR request. This gives a clear idea why the button is disabled and what is happening in the application also user can also see when the button is going to enable again, its when the loader will stop loading.

sethsandaru commented 3 years ago

@abhimanusharma That's cool, thanks for sharing!

sethsandaru commented 3 years ago

On going for the last one - Read-only Form.