Giter Site home page Giter Site logo

bem-forms's Introduction

bem-forms's People

Contributors

adinvadim avatar aristov avatar awinogradov avatar belozer avatar dragn avatar qfox avatar s-panferov avatar tadatuta avatar voischev avatar

Stargazers

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

Watchers

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

bem-forms's Issues

form_validate

  1. Run validates on submit
  2. Has setMessage() and getMesssage() like form__field_validate

Few variants of form: form_simple, form_fields, form_else

  1. form_simple will search for form__controls and provide all of them to validation block or user's code. Also it will provide all of data from them.
  2. form_fielded will search for form__field (complex proxy blocks) with the same interface that will provide already assembled data from from__controls that assigned to __fields.
  3. Any other form types possible with pure interfaces library provided by form's elements.

It will allow us to make flexible form variator that can be extended in future with other helpers, interfaces and form types. Any abandoned ideas will be moved out with new releases. Simple.

Do we need `form-field` block?

  1. .form-field__message vs .form__field-message or .form__field .form__message or form__field_with-message
  2. form-field_type_input vs form__field_type_input
  3. form-field__control vs form__control

etc.

form-field name

{
    block : 'form-field',
    name : 'lastName',
    content : []
}

Fix formField.getName()

think about validation event

On project level overriding is very bad. I need info about base events and disable its, then write custom events.

form__field-like interface to create any __controls and __fields

We should refine this interface and move it out to separate element which be used by form.

Some guesses for name:

  • form__tuple
  • form__key-value
  • form__name-value

This one can be a BEM-block with a simple interface:

  • {*} getVal()
  • void setVal({*})
  • {string|Object} getName()

Do we need something else here?

It will be used as a base interface for form__field/__control blocks.

form__field_validate

Common mod for validate field value

Mod values

  1. Card
  2. Email
  3. Money
  4. Pattern
  5. Numbers
  6. Required

form: add enctype attr

Очень часто форма используется с multipart/form-data

{
            block : 'form',
            tag : 'form',
            attrs : {
                action : '/posts/',
                enctype : 'multipart/form-data',
                method : 'post'
            },
            content : []
}

set status mods on form-field message

Проблемы при пробрасывании положения popup. Как-то надо этот момент порешать. Положение у popup, стили у message, нужны стили от message на положение popup

form-field messages

  1. form-field tmpls(connect with message block), depend on #1
  2. setMessage() and getMessage()

Why do we need 'has-validate' mod on form-field?

Why do we need has-validate mod on form-field? The same thing is denoted by the presence of validate mod...
Moreover, I think it would be better to setup validators not through mods, but with a parameter, and support multiple validators, the example interface could be:

{
    block : 'form-field',
    validators : [
        {
            type : 'required',
            message : 'Введите номер карты' // could contain error message
        },
        'card', // could be just string
        {
            type : 'regex',
            pattern : /^4.*/, // could contain extra parameters
            message : 'Тип карты не поддерживается'
        }
    ]
}

Validation block and API

We using it as a mix for input (or similar) blocks right now:

{
  block : 'input',
  mods : { theme : 'islands' },
  mix : [
    { block : 'form', elem : 'control' },
    { block : 'validation', mods : { numbers : true }, js : {/* validation params */} }
  ]
}

There is a lot of data that we should pass for each field and I really want to simplify it if possible.

Any guesses will help a lot.

The one that placed on the top of my mind probably have troubles with theme deps:

{
  elem : 'control',
  mods : { type : 'text', theme : 'islands', size : 'l', validation : 'numbers' },
  js : { validation : { /* validation params */ } }
}

control_validation_numbers will require validation_numbers block, form__control_type_text will require input and input_type_text, and form__control_theme_islands will require input_theme_islands. Right?
Also it can internally regenerate the rest of needed bemjson by BH/BEMHTML but I'm afraid of missing deps here and need review.

I think that's all validation block needed to return some validation result. All other work with form should be placed in form_validation.

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.