Jafar

Jafar

  • Docs
  • Form Demos
  • Components Demos
  • Layout Demos
  • Editor
  • GitHub

›Advanced Usages

Getting started

  • Introduction

Form Class

  • Installation
  • Overview
  • Arguments
  • Id
  • Data
  • Fields
  • Path
  • Component
  • Formatter & Parser
  • Dependencies
  • Required
  • Validators
  • Exclude Term
  • Disable Term
  • Require Term
  • Dependencies Change
  • Context
  • Dirty
  • Invalid
  • Errors
  • Processing
  • Pending Actions
  • Hooks
  • Term
  • Log
  • Error Codes
  • Actions
  • Definition Shorthand

Advanced Usages

  • Grid Usage
  • Form Persistency
  • Undo & Redo
  • Replay Actions
  • Track Actions
  • Server Validation
  • Entity Templates
  • Folder Structure

React Form

  • Installation
  • Overview
  • Form
  • Field
  • Components
  • Layout
  • Demos

More Info

  • Test Jafar
  • Packages
  • Why Jafar?
  • Videos
  • Channels

Contribute

  • Code of Conduct
  • Contributing Guide
  • Contributors

Folder Structure

Large / massive form contains a lot of code and definitions. In order to keep code as simple and intuitive as possible we recommend the following folder structure for a form definition:

  • form
    • fields
      • first-name.js
      • last-name.js
      • friends.js
      • job-type.js
      • index.js
    • validators
      • unique-field.js
      • correct-format.js
      • index.js
    • terms
      • is-allowed.js
      • index.js
    • conversions
      • friends-to-array.js
      • index.js
    • dependencies-changes
      • friends-dependencies-changes.js
      • index.js
    • hooks
      • after-action.js
      • validate.js
      • submit.js
      • index.js
    • components
      • Friends.js
      • index.js
    • data.js
    • index.js

form/index.js

Aggregates all form's definition into 2 objects - model and resources, and export them.

import fields from './fields';
import data from './data';
import validators from './validators';
import terms from './terms';
import conversions from './conversions';
import dependenciesChanges from './dependencies-changes';
import hooks from './hooks';

const model = {
  id: 'employee',
  fields,
  data,
};

const resource = {
  validators,
  terms,
  conversions,
  dependenciesChanges,
  hooks,
};

export default { model, resources };

form/data.js

Exports default / initial data of a form.

export default {
  jobType: 'SOFTWARE_ENGINEER',
};

form/fields/index.js

Aggregates all form's fields into one object and export it.

import firstName from './first-name';
import lastName from './last-name';
import friends from './friends';
import jobType from './job-type';

export default {
  firstName,
  lastName,
  friends,
  jobType,
};

form/validators/index.js

Aggregates all form's custom validators into one object and export it. No need to define built-in validators

import uniqueField from './unique-field.js';
import correctFormat from './correct-format.js';

export default { 
  uniqueField,
  correctFormat,
};

form/terms/index.js

Aggregates all form's custom terms into one object and export it. No need to define built-in terms

import uniqueField from './unique-field.js';
import correctFormat from './correct-format.js';

export default { 
  uniqueField,
  correctFormat,
};

form/conversions/index.js

Aggregates all form's custom conversions into one object and export it. No need to define built-in conversions

import friendsToArray from './friends-to-array.js';

export default { 
  friendsToArray,
};

form/dependencies-changes/index.js

Aggregates all form's dependencies changes into one object and export it.

import friendsToArray from './friends-to-array.js';

export default { 
  friendsToArray,
};

form/hooks/index.js

Aggregates all form's hooks into one object and export it.

import afterAction from './after-action.js';
import validate from './validate.js';
import submit from './submit.js';

export default { 
  afterAction,
  validate,
  submit,
};

form/components/index.js

Aggregates all form's components into one object and export it.

import InputText from '@jafar/react-components/edit/Text';
import Select from '@jafar/react-components/view/Select';
import Friends from './Friends.js'; // custom component - exports object { renderer, stateChange }

export default { 
  InputText: { 
    renderer: InputText, 
  },
  Select: { 
    renderer: Select, 
  },
  Friends,
};
← Entity TemplatesInstallation →
  • form/index.js
  • form/data.js
  • form/fields/index.js
  • form/validators/index.js
  • form/terms/index.js
  • form/conversions/index.js
  • form/dependencies-changes/index.js
  • form/hooks/index.js
  • form/components/index.js
Jafar
Copyright © 2020 Verizon Media
DOCS
IntroductionForm ClassReact FormReact ComponentsReact Layout
DEMOS
React FormReact ComponentsReact Layout
CONTRIBUTING
Code Of ConductContributing GuideUsers
CHANNELS
StarGitHubStack OverflowMediumVideos