Skip to content

mixin form.twig

Aleksey Ilyin edited this page May 6, 2022 · 5 revisions

Generates a Bootstrap compliant block <div data-input class="checkbox|radio|form-group" ...

Usage

{% include 'mixin/form.twig' with {
    'label': 'Login',
    'description': 'Username or email',
    'message': 'Be careful',
    'prefix': 'Before field',
    'postfix': 'After field',
    'type': 'text', // text|email|tel|number|checkbox|radio
    'name': 'my-field-name',
    'args': {
        'method': 'post',
        'style': 'color: red;',
        'class': ['d-block', 'p-3'],
        'data': {
            'arg1': 'val1', 'arg2': ''
        },
        'option': {
            'yes':'Yes', 'no':'No'
        },
        'placeholder': 'Enter text..',
        'value': '8',
        'step': 2,
        'min': 0,
        'max': 10,
        'selected': 'yes',
        'checked': false,
        'disabled': false,
        'readonly': true,
    }
} %}

Mixin works with any type of HTML5 field input, textarea, select.

Also received during use, the field will receive the value from the current POST or GET parameters, and also receive the has-error class in case the field is filled with an error.

SRC

/src/Template/mixin/form.twig

Clone this wiki locally