# sb-form

> SB Form is a dynamic form build with vue3 for laravel and vue application

Latest version **1.0.4** (published 2025-02-15) · 0 weekly downloads

## Install

```sh
npm install sb-form
pnpm add sb-form
yarn add sb-form
bun add sb-form
```

## Health

**Score 30/100 (F)** — status: maintenance-mode.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2025-02-15 |
| First published | 2022-05-15 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 6 |
| Unpacked size | 872.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | K M Rifat ul alom |
| Maintainers | kmrifat |
| Keywords | vue dynamic form, laravel vue form |

## Links

- npm: https://www.npmjs.com/package/sb-form
- Homepage: https://github.com/kmrifat/sb-form
- npm.io page: https://npm.io/package/sb-form

## Dependencies (6)

- [vue](https://npm.io/package/vue.md) ^3.2.25
- [toastr](https://npm.io/package/toastr.md) ^2.1.4
- [bootstrap](https://npm.io/package/bootstrap.md) ^5.2.0-beta1
- [vue-router](https://npm.io/package/vue-router.md) ^4.1.2
- [@popperjs/core](https://npm.io/package/@popperjs/core.md) ^2.11.5
- [laravel-vue-pagination](https://npm.io/package/laravel-vue-pagination.md) ^3.0.0

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.0.4 (latest) — 2025-02-15
- 1.0.3-preview.2 (preview) — 2025-02-15
- 0.1.2 (beta) — 2022-07-03
- 1.0.3 — 2025-02-15
- 1.0.3-preview.1 — 2025-02-15
- 1.0.1 — 2025-02-15
- 1.0.0 — 2025-02-15
- 0.2.35 — 2025-02-12
- 0.2.34-preview — 2025-02-11
- 0.2.34 — 2025-02-09
- 0.2.33 — 2025-02-06
- 0.2.32 — 2025-02-03
- 0.2.31-preview — 2025-01-23
- 0.2.31 — 2025-01-15
- 0.2.30 — 2025-01-06
- … 33 more at https://npm.io/package/sb-form/versions

## README

# SB Form

#### Designed for Laravel + Vue Appliction

This form is design to build from a json, it will help us to develop application so rapidly that we don't need to worry
about form validation from design and file management

## Uses

To use Sb form you need to register the `Index.vue` to your `main.js`. <br>
or <br>
You can import `Index.vue` from the `sb-form` directory and use this component <br>

I register the SB Form alias to `sb-form` sp we can use it entire the application using `<sb-form/>` tag

### Supported Props

```json5
{
    props: {
        title: String,
        fields: Object,
        url: String,
        resetForm: {
            type: Boolean,
            default: true
        },
        callBack: {
            type: String,
            required: false
        }
    }
}
```

Currently, SB Form is support the listed props above. <br>
`title`, `fields` and `url` is required <br>
`callBack` will only execute on axios success
`resetForm` we can revoke from reset on edit/update <br>
The base (with all required props) db-form will look like this

```html

<sb-form title="Create User" :fields="fields" url="/create-user"/>
```

## Supported Fields

- [x] [Input Field](#input-field) `string`
- [x] [Password Field](#password-field) `password`
- [x] [Text Field](#text-field) `text_field`
- [x] [Single Select Field](#single-select-field) - Ajax Support need to add `select_field`
- [x] [Multiple Select Field](#multiple-select-field)
- [x] [File Field (Support File Upload)](#file-field) `file_field`

Scroll down more to get more information about the fields listed above

### Field Basic

Checkout the basic schema of json to generate a html field

```json5
{
    role: {
        label: 'Role',
        col: 6,
        type: 'select_field',
        value: 1,
        options: [
            {
                id: 1,
                name: 'Super Admin'
            },
            {
                id: 2,
                name: 'Role Two'
            }
        ],
        config: {
            value: 'id',
            display: 'name'
        }
    }
}
```

Name of the json attribute `role` will be considered as `v-model`
so you will see the same name in request payload.

`label` will be consider as your html label of the field

`col` bootstrap column. by default, it's `col-12`
so you can skip it if you don't want to change the column

`type` You need to define the [filed type](#supported-fields) here. by default, it will take `string`

`value` It will need in edit form when you like to preset data in `v-model`

`options` Only need in Select and Multiselect

`config` Currently it's also using in Select Field Only

### Input Field

```json5
{
    name: {
        label: "Full Name",
        placeholder: "Enter Full Name",
        col: 6,
        required: true
    }
}
```

### Text Field

```json5
{
    address: {
        label: "Address",
        col: 12,
        type: 'text_field'
    }
}
```

### Password Field

```json5
 {
    password: {
        label: "Password",
        col: 6,
        type: 'password',
        required: true
    }
}
```

### Single Select Field

```json5
{
    role: {
        label: 'Role',
        col: 6,
        type: 'select_field',
        value: 1,
        options: [
            {
                id: 1,
                name: 'Super Admin'
            },
            {
                id: 2,
                name: 'Role Two'
            }
        ],
        config: {
            value: 'id',
            display: 'name'
        }
    }
}
```

### Multiple Select Field
```json5
{
    permissions: {
        label: 'Permissions',
        type: 'multiselect_field',
        options: [
            {id:  1, name:  'Create User'}
        ],
        config: {
            value: (value) => value.id,
            display: (value) => value.name,
        },
        ajax: '/ajax-url'
    }
}
```

### File Field

```json5
{
    image: {
        label: 'User Image',
        type: 'file_field'
    }
}
```

---
_Source: https://npm.io/package/sb-form · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
