{% macro input(id, name='', value='', type='text', size='', readonly='', required='', placeholder='', autofocus='', title='', class='form-control', style='') -%}
	{% if name == '' %}
		{% set name = id %}
	{% endif %}
	{# {% if readonly == '' %}
		{% set readonly = 'readonly  onfocus=this.removeAttribute(\'readonly\');' %}
	{% endif %} #}
    <input type="{{ type }}" name="{{name}}" value="{{ value|e }}" id="{{ id }}" size="{{size}}" style="{{style}}" {{readonly}} {{required}} {{autofocus}} placeholder="{{placeholder}}" title="{{title}}" class="{{class}}" autocomplete="off" />
{%- endmacro %}

{%- macro checkbox(id, name='', checked='', title='', value='', desc='') -%}
	{% if name == '' %}
		{% set name = id %}
	{% endif %}
	<label for="{{id}}" title="{{title}}" class="{{id}}">{{desc}}</label><input name="{{name}}" type="checkbox" id="{{id}}" value="{{value|e}}" {{checked}} />
{%- endmacro %}

{%- macro select(id, values, name='', required='', first='', class='', selected='', disabled='true') -%}
	{% if name == '' %}
		{% set name = id %}
	{% endif %}
	{% if disabled == 'true' %}
		{% set disabled = 'disabled' %}
	{% else %}
		{% set disabled = '' %}
	{% endif %}
	<select {{required}} name="{{name}}" id="{{id}}" class="{{class}}">
		{% if first %}
			<option {{disabled}} selected>{{first}}</option>
		{% endif %}
		{% for v, des in values|dictsort(false, 'value') %}
			{% if v == selected %}
				<option value="{{v}}" selected>{{des}}</option>
			{% else %}
				<option value="{{v}}">{{des}}</option>
			{% endif %}
		{% endfor %}
	</select>
{%- endmacro %}