The Framework Code

twigs/framework/devel/tests/formother.twig

File List

{% import '@util/formmacro.twig' as f %}
{% import _self as me %}

{% macro makehash(hash, extra) %}
    {% set res = '{' %}
    {% for key,value in hash %}
        {% set res = "#{res}#{key}: \"#{value}\"" %}
        {% if not loop.last %}
            {% set res = "#{res}," %}
        {% endif %}
    {% endfor %}
    {% for key,value in extra %}
        {% set res = "#{res},#{key}: \"#{value}\"" %}
    {% endfor %}
    {% set res = "#{res}}" %}
    {{res}}
{% endmacro makehash %}

{% macro ndr(mname, opts) %}
    {% import '@util/formmacro.twig' as f %}
    {% import _self as h %}
    {{attribute(f, mname, opts)}}
{% endmacro ndr %}

    {{f.startform({id: 'tform2', on: {submit: 'function(e){fwdom.stop(e);}'} })}}
        {{f.number({label: 'Number', id : 'nmid1', name: 'nm1', value: 42, min: 30, step: 2, max: 50})}}
        {{f.number({label: 'Number Disabled', id : 'nmid2', name: 'nm2', value: 42, min: 30, step: 2, max: 50, disabled: TRUE})}}
        {{f.number({label: 'Number Readonly', id : 'nmid3', name: 'nm3', value: 42, min: 30, step: 2, max: 50, readonly: TRUE})}}

        {{f.range({label: 'Range', id : 'rnid1', name: 'rn1', dvalue: 15, min:10, step: 1, max: 20})}}
        {{f.range({label: 'Range Disabled', id : 'rnid2', name: 'rn2', dvalue: 15, min:10, step: 1, max: 20, disabled: TRUE})}}
        {{f.range({label: 'Range Readonly', id : 'rnid3', name: 'rn3', dvalue: 15, min:10, step: 1, max: 20, readonly: TRUE})}}

        {{f.date({label: 'Date', id : 'dttid', name: 'dt', ph: 'date type'})}}
        {{f.date({label: 'Date (disabled)', id : 'dttid', name: 'dt', ph: 'date type', disabled: TRUE})}}
        {{f.date({label: 'Date (readonly)', id : 'dttid', name: 'dt', ph: 'date type', readonly: TRUE})}}
        {{f.datetime({label: 'DateTime(-local)', id : 'dtid', name: 'dt', ph: 'date time local type'})}}
        {{f.datetimelocal({label: 'DateTime-Local', id : 'dttlid', name: 'dt', ph: 'date time local type'})}}
        {{f.time({label: 'Time', id : 'dtid', name: 'tm', ph: 'time type'})}}

        {{f.file({label: 'File', id : 'flid', name: 'fl', accept: 'image/png'})}}
        {{f.file({label: 'File Disabled', id : 'flid', name: 'fl', accept: 'image/png', disabled: TRUE})}}
        {{f.file({label: 'File Multiple', id : 'flid', name: 'flm[]', accept: 'image/png', multiple: TRUE})}}
        {{f.file({label: 'File Multiple Disabled', id : 'flidm[]', name: 'fl', accept: 'image/png', disabled: TRUE, multiple: TRUE})}}

        {% set options = [
            {text: '—Select—', value: ''},
            {text: 'Value 1', value: 1},
            {text: 'Value 2', value: 2},
            {text: 'Value 3', value: 3},
            {text: 'Value 4', value: 4},
            {text: 'Value 5', value: 5},
        ] %}
        {{f.select({label: 'Select', is: 'slid21', name: 'sl21', selected: 1, options: options})}}
        {{f.select({label: 'Select Disabled', is: 'slid22', name: 'sl22', selected: 1, disabled: TRUE, options: options})}}

        {{f.select({label: 'Select Multiple', is: 'slid11', name: 'sl11', size: 3, multiple: TRUE, selected: [1, 4], options: options})}}
        {{f.select({label: 'Select Multiple Disabled', is: 'slid12', name: 'sl12', size: 3, multiple: TRUE, selected: [1, 4], options: options, disabled: TRUE})}}

        {{f.checkbox({group: TRUE, label: 'Checkboxes', ids : ['nic1', 'nic2', 'nic3'], names: ['nc1', 'nc2', 'nc3'], labels: [1, '2 (disabled)', 3], values: [ 1, 2, 3], check: [FALSE, FALSE, TRUE], disabled: [FALSE, TRUE, FALSE]})}}
        {{f.checkbox({group: TRUE, label: 'Inline Checkboxes', inline: TRUE, ids : ['ic1', 'ic2', 'ic3'], names: ['c1', 'c2', 'c3'], labels: [1, '2 (disabled, checked)', 3], values: [ 1, 2, 3], check: [FALSE, TRUE, TRUE], disabled: [FALSE, TRUE, FALSE]})}}
        {{f.radio({group: TRUE, label: 'Radios', ids : ['nir1', 'nir2', 'nir3'], names: ['nr1', 'nr1', 'nr1'], labels: [1, '2 (disabled)', 3], values: [ 1, 2, 3], check: [TRUE, FALSE, FALSE], disabled: [FALSE, TRUE, FALSE]})}}
        {{f.radio({group: TRUE, label: 'Inline Radios', inline: TRUE, ids : ['ir1', 'ir2', 'ir3'], names: ['r1', 'r1', 'r1'], labels: [1, '2 (disabled)', 3], values: [ 1, 2, 3], check: [TRUE, FALSE, FALSE], disabled: [FALSE, TRUE, FALSE]})}}

        <p>{{f.submit({value: 'Submit Button', bstyle: 'btn-info'})}}</p>
        <p>{{f.submit({value: 'Submit Button Disabled', bstyle: 'btn-info', disabled: TRUE})}}</p>
        <p>{{f.bsubmit({rvalue: 'Submit Button Allowing <i>HTML</i>', bstyle: 'btn-info'})}}</p>
        <p>{{f.bsubmit({rvalue: 'Submit Button Allowing <i>HTML</i> Disabled', bstyle: 'btn-info', disabled: TRUE})}}</p>
    {{f.endform()}}