{# templates/mdl/fields/input.html.twig #}
{% with {
InputMDL: {
'Wrapper': {
'defaults': {
'class': 'mdl-textfield mdl-js-textfield mdl-textfield--floating-label'
}
},
'Label': {
'defaults': {
'class': 'mdl-textfield__label mdl-color-text--grey'
},
'excludes': ['text']
},
'Input': {
'defaults': {
'class': 'mdl-textfield__input mdl-color-text--primary'
}
},
'Error': {
'defaults': {
'class': 'mdl-textfield__error'
},
'excludes': ['text']
}
}
} %}
<div {%
for attr, value in Wrapper
%}{{ attr }}{%
if value is not same as(true)
%}="{{ value|replace( { '~' : attribute(attribute(attribute(InputMDL, 'Wrapper'), 'defaults'), attr) ?? '' } ) }}"{%
endif
%} {%
endfor %}>
<label {%
for attr, value in Label %}{% if attr not in (attribute(attribute(InputMDL, 'Label'), 'excludes') ?? [])
%}{{ attr }}{%
if value is not same as(true)
%}="{{ value|replace( { '~' : attribute(attribute(attribute(InputMDL, 'Label'), 'defaults'), attr) ?? '' } ) }}"{%
endif
%} {%
endif %}{% endfor
%}>{{Label.text ?: ''}}</label>
<input {%
for attr, value in Input %}{% if attr not in (attribute(attribute(InputMDL, 'Input'), 'excludes') ?? [])
%}{{ attr }}{%
if value is not same as(true)
%}="{{ value|replace( { '~' : attribute(attribute(attribute(InputMDL, 'Input'), 'defaults'), attr) ?? '' } ) }}"{%
endif
%} {%
endif %}{% endfor
%}/>
<span {%
for attr, value in Error %}{% if attr not in (attribute(attribute(InputMDL, 'Error'), 'excludes') ?? [])
%}{{ attr }}{%
if value is not same as(true)
%}="{{ value|replace( { '~' : attribute(attribute(attribute(InputMDL, 'Error'), 'defaults'), attr) ?? '' } ) }}"{%
endif
%} {%
endif %}{% endfor
%}>{{Error.text ?: ''}}</span>
</div>
{% endwith %}