Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@labshare/ngx-forms

Package Overview
Dependencies
Maintainers
29
Versions
66
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@labshare/ngx-forms

[![Greenkeeper badge](https://badges.greenkeeper.io/LabShare/ngx-forms.svg?token=4a12f6b1da0f082ac1bbf2c72bbcaf01b001705746c61c36eee1db6bda3d7c11&ts=1528346534395)](https://greenkeeper.io/) [![Coverage Status](https://coveralls.io/repos/github/LabShare/ng

  • 1.1.0
  • npm
  • Socket score

Version published
Weekly downloads
6
decreased by-40%
Maintainers
29
Weekly downloads
 
Created
Source

Greenkeeper badge Coverage Status semantic-release

ngx-forms

Dynamic form generator. This module provides components that wrap angular 2+ FormBuilder styled with Bootstrap CSS 4 Alt text

Requirements

  • angular 2+

Installation

npm install

Linking

npm run build:watch

Usage

Add html tag with bindings <dynamic-form [config]="config" #form="dynamicForm" [model]="project"></dynamic-form>

  • config - json array that contains fields definitions
  • #form="dynamicForm" - bind to dynamicForm object that has form output
  • model - preload data. One way binding only

Config example

[
    { type: 'hidden', name: 'id' },
    { type: 'text', label: 'Title', name: 'title', placeholder: 'Enter project title', required: true, max: 14 },
    { type: 'text', label: 'Name', name: 'activityName', placeholder: 'Enter project name', minLength: 2, maxLength: 5 },
]

Field options and examples

NameTypeDescriptionExample
disabled?booleandisable field if truedisabled: true
label?stringfield labellabel: "Project Title"
namestringfield namename: "projectTitle"
options?any[]options for <select> dropdown or radio buttonsoptions: [ "Option 1", "Option 2" ]
placeholder?stringtext placeholderplaceholder: "Enter Project Title"
typestringfield type (see field type description)type: "select"
value?anyfield valuevalue: 123
required?booleanValidation: required or notrequired: true
minLength?numberValidation: minimum length of a text fieldminLength: 5
maxLength?numberValidation: maximum length of a text fieldmaxLength: 12
email?booleanValidation: field must be an email addressemail: true
min?numberValidation: minumum value for number fieldsmin: 100
max?numberValidation: maximum value for number fieldsmax: 1000
pattern?RegExpValidation: regular expressionpattern: "^[a-zA-Z0-9_]*$"
nullValidator?anyValidation: null validationnullValidator: true
hiddenbooleanhide the field by default when the form loadinghidden: true

Field types

  • text - text input <input type="text">
  • select - text unput <select>
  • textarea - text input <textarea>
  • editor - Rich text editor based on ngx-quill
  • hidden - hidden value field <input type="hidden">.
  • radio - radio buttons
  • checkbox - checkbox buttons

Interaction between two fields

Show a new field by selecting a radio button

Alt text When users select a value of radio button, a new field which name is same with ref in options will show up. If ref in that option is missing, it will not show anything and reverse the status back.

Field example

{ "type": "radio", "label": "Were NCATS core facilities used?", "name": "questions", "options": [{"value": "Yes", "ref": "checkId"}, {"value": "No"}]},
{ "type": "checkbox", "label":"Identify all that apply", "name": "checkId", "hidden": true, "options": [{"value": "NIH Grant"}, {"value": "NIH Intramural"}]}

So when users select radio button Yes, it will look for the field with name checkID and show the checkbox. When No is selected, the checkbox will hide because there is no value in ref.

FAQs

Package last updated on 25 Jun 2018

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc