bem-contrib / bem-forms Goto Github PK
View Code? Open in Web Editor NEWForms building library on BEM methogology
Forms building library on BEM methogology
null val is 0
form_simple
will search for form__control
s and provide all of them to validation
block or user's code. Also it will provide all of data from them.form_fielded
will search for form__field
(complex proxy blocks) with the same interface that will provide already assembled data from from__control
s that assigned to __field
s.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.
Block label
is for add labels to controls in some standard way.
Card validation returns wrong_length error for 16 digits.
Need: message || DEFAULT_MESSAGE
.form-field__message
vs .form__field-message
or .form__field .form__message
or form__field_with-message
form-field_type_input
vs form__field_type_input
form-field__control
vs form__control
etc.
{
block : 'form-field',
name : 'lastName',
content : []
}
Fix formField.getName()
On project level overriding is very bad. I need info about base events and disable its, then write custom events.
Mix message on popup
depend for #12
Depend on bem/bem-components#1379
Block message
is for show validation errors and other messages.
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.
Common mod for validate field value
Mod values
Очень часто форма используется с multipart/form-data
{
block : 'form',
tag : 'form',
attrs : {
action : '/posts/',
enctype : 'multipart/form-data',
method : 'post'
},
content : []
}
If i add new field, form don't know about it and validation don't work
All error messages should be objects (?) or strings
Normalize all validators:
Проблемы при пробрасывании положения popup
. Как-то надо этот момент порешать. Положение у popup
, стили у message
, нужны стили от message
на положение popup
jshint, jscs, npm run lint
message
block), depend on #1Why 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 : 'Тип карты не поддерживается'
}
]
}
Validations types is mods. Info about this method
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
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.