GithubHelp home page GithubHelp logo

cerebral-legacy / cerebral-module-forms Goto Github PK

View Code? Open in Web Editor NEW
12.0 12.0 5.0 114 KB

Form handling for Cerebral

Home Page: http://cerebral-website.herokuapp.com/documentation/cerebral-module-forms

License: MIT License

JavaScript 100.00%

cerebral-module-forms's People

Contributors

abalmos avatar alafkas avatar christianalfoni avatar edgesoft avatar fvgoto avatar guria avatar henri-hulski avatar saulshanabrook avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

cerebral-module-forms's Issues

Async demo not working

The async demo is not working. In the react/input we do not call the onBlur function. Needs to be fixed.

validateForm issue

in actions/validateForm line 32 36

var isValid = result.isValid && !isRequired(field);
errorMessage: isValid ? null : field.errorMessages[result.failedRuleIndex],

the result.failedRuleIndex is 0 if it pass.
we don't know which the error is.

hasValue returns rules[key] is not a function

If we set up forms with isValue and pass parameter to it this error will occur.

rules[key] is not a function

form

name: {
  value: [],
  isValue: ['minLength:3']
} 

The isValue needs to be parsed and also passed to the rule.

equalsField

In helpers/rules.js we have this rule.

 equalsField: function (value, form, field) {
    return value == form[field];
  },

Should this be return value === form[field].value?

How best to do update form

None of the demo projects seems to cover the use case of a form used for updating data, in all cases the 'value' of each field is set when the form is added to state. To make it work I am using code along the following lines in an action when the update form (teamInputForm) is opened:

  const {teams, selectedId} = state.get();
  const {id, name} = teams[selectedId];
  state.set(['teamInputForm', 'id', 'value'], id);
  state.set(['teamInputForm', 'name', 'value'], name);

Is this the best way to approach this? I'm happy to contribute an update form example to the demos if anyone can confirm the best approach.

Thanks, Colin

isTouched field not working?

Hi, I'm assuming isTouched is to determine whether or not the form field is dirty or not. So, when the end user modifies the input so that it no longer matches the default value, then isTouched = true

If the above is correct, it doesn't seem to be working. If the default value is "" then isTouched is always false. When default value is set to some string like "foo" then isTouched is always true.

Using "cerebral-module-forms": "^0.2.7"

extensibility

Looks like any extra support (focus control, debounced validation, etc) requires to build own chains and register it in app level.
Currently index.js is very simple and in fact could be not used at all, if you decide to build your own chains.
Maybe we should better provide actions, factories, uttilities, etc in cerebral-forms package without module. We still can have cerebral-module-forms with default setup as easy start point.

isValid is inconsistent.

I think we need a better way to handle isValid.

If a field is not required and has no value, we should not run the validations as all and isValid=true&errorMessage=null.

Otherwise, always run the validations when a field is added or its value is updated.

React 15 warnings

React 15 complains about controlled and uncontrolled inputs. We can not have defaultValue and value in the inputs. Since cerebral is controlling the input we should remove defaultValue from the demo so we don't get all the warnings in the console.

isNumeric rule returns true on NaN

Hi, not sure if this is a desired behavior or not, but, if the isNumeric rule is passed NaN, it will return true. Technically, in the javascript world, this is working properly, but, in human terms, I think that it should return false for NaN. Thoughts?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.