Socket
Book a DemoInstallSign in
Socket

nftrace-form-builder

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nftrace-form-builder

A customized dynamic form builder for react.

0.4.8
latest
Source
npmnpm
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

npm version downloads

Fork of Form-Builder By Kiho

React Form Builder 2

A complete react form builder that interfaces with a json endpoint to load and save generated forms.

  • Upgraded to React 16.8.6
  • Bootstrap 4.x, Font-Awesome 5.x
  • Use react-dnd for Drag & Drop
  • Save form data with dummy api server
  • Show posted data on readonly form
  • Multi column row

DEMO Slow Loading.... back-end is running at FREE Heroku.

Editing Items

Basic Usage

import React from 'react';
import ReactDOM from 'react-dom';
import { ReactFormBuilder } from 'react-form-builder2';
import 'react-form-builder2/dist/app.css';

ReactDOM.render(
  <ReactFormBuilder />,
  document.body
)

Props

var items = [{
  key: 'Header',
  name: 'Header Text',
  icon: 'fa fa-header',
  static: true,
  content: 'Placeholder Text...'
},
{
  key: 'Paragraph',
  name: 'Paragraph',
  static: true,
  icon: 'fa fa-paragraph',
  content: 'Placeholder Text...'
}];

<ReactFormBuilder
  url='path/to/GET/initial.json'
  toolbarItems={items}
  saveUrl='path/to/POST/built/form.json' />

React Form Generator

Now that a form is built and saved, let's generate it from the saved json.

import React from 'react';
import ReactDOM from 'react-dom';
import { ReactFormGenerator } from 'react-form-builder2';
import 'react-form-builder2/dist/app.css';

ReactDOM.render(
  <ReactFormGenerator
    form_action="/path/to/form/submit"
    form_method="POST"
    task_id={12} // Used to submit a hidden variable with the id to the form from the database.
    answer_data={JSON_ANSWERS} // Answer data, only used if loading a pre-existing form with values.
    authenticity_token={AUTH_TOKEN} // If using Rails and need an auth token to submit form.
    data={JSON_QUESTION_DATA} // Question data
  />,
  document.body
)

Form Params

NameTypeRequired?Description
form_actionstringRequiredURL path to submit the form
form_methodstringRequiredVerb used in the form submission.
action_namestringOptionalDefines form submit button text. Defaults to "Submit"
onSubmitfunctionoptionalInvoke when submit data, if exists will override form post.
dataarrayRequiredQuestion data retrieved from the database
back_actionstringOptionalURL path to go back if needed.
back_namestringOptionalButton text for back action. Defaults to "Cancel".
task_idintegerOptionalUser to submit a hidden variable with id to the form on the backend database.
answer_dataarrayOptionalAnswer data, only used if loading a pre-existing form with values.
authenticity_tokenstringOptionalIf using Rails and need an auth token to submit form.
hide_actionsbooleanOptionalIf you would like to hide the submit / cancel buttons set to true.
skip_validationsbooleanOptionalSuppress form validations on submit, if set to true.
display_shortbooleanOptionalDisplay an optional "shorter page/form" which is common for legal documents or situations where the user will just have to sign or fill out a shorter form with only the critical elements.
read_onlybooleanOptionalShows a read only version which has fields disabled and removes "required" labels.
variablesobjectOptionalKey/value object that can be used for Signature variable replacement.

Read only Signatures

Read only signatures allow you to use a saved/canned signature to be placed into the form. The signature will be passed in through the variables property to ReactFormGenerator and ReactFormBuilder.

To use a read only signature, choose the "Read only" option and enter the key value of the variable that will be used to pass in the signature.

The signature data should be in base 64 format.

There is a variables.js file that contains a sample base 64 signature. This variable is passed into the demo builder and generator for testing. Use the variable key "JOHN" to test the variable replacement.

Vendor Dependencies

In order to make the form builder look pretty, there are a few dependencies other than React. Style sheets from Bootstrap and FontAwesome must be added to index.html. See the example code in index.html for more details.

  • Bootstrap
  • FontAwesome

SASS

All relevant styles are located in css/application.css.scss.

Develop

First we need to start nftrace admin project because in file upload component we are storing the uploaded file from the server so at first we need to start the nftrace admin in http://localhost:4000

$ npm install
$ npm run build:dist
$ npm run serve:api
$ npm start

Then navigate to http://localhost:8080/ in your browser and you should be able to see the form builder in action.

Examples

Tests

$ npm test

Test is not working at this moment.

Issues

if you face any unknown issues after deployed in live on form builder file upload or file edit that maybe because of the react-filerobot-image-editor version we need to find the correct version and use that. right now im using "react-filerobot-image-editor": "^4.0.0-beta.38",

Keywords

react

FAQs

Package last updated on 19 Oct 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.