templates/mdl/fields/textfield.html.twig line 1

Open in your IDE?
  1. {# templates/mdl/fields/textfield.html.twig #}
  2. {% with { 
  3.     tfEls: {
  4.         'Wrapper': {
  5.             'defaults': {
  6.                 'class': 'mdl-textfield mdl-js-textfield mdl-textfield--floating-label'
  7.             }
  8.         },
  9.         'Label': {
  10.             'defaults': {
  11.                 'class': 'mdl-textfield__label mdl-color-text--grey'
  12.             },
  13.             'excludes': ['text']
  14.         },
  15.         'Input': {
  16.             'defaults': {
  17.                 'class': 'mdl-textfield__input mdl-color-text--primary'
  18.             }
  19.         },
  20.         'Error': {
  21.             'defaults': {
  22.                 'class': 'mdl-textfield__error'
  23.             },
  24.             'excludes': ['text']
  25.         }
  26.     }
  27. } %}
  28. <div {% 
  29.     for attr, value in Wrapper
  30.         %}{{ attr }}{%
  31.         if value is not same as(true)
  32.             %}="{{ value|replace( { '~' :  attribute(attribute(attribute(tfEls, 'Wrapper'), 'defaults'), attr) ?? '' } ) }}"{%
  33.         endif
  34.         %} {% 
  35.     endfor %}>
  36.     <label {% 
  37.         for attr, value in Label %}{% if attr not in (attribute(attribute(tfEls, 'Label'), 'excludes') ?? [])
  38.             %}{{ attr }}{% 
  39.             if value is not same as(true) 
  40.                 %}="{{ value|replace( { '~' :  attribute(attribute(attribute(tfEls, 'Label'), 'defaults'), attr) ?? '' } ) }}"{% 
  41.             endif
  42.             %} {% 
  43.         endif %}{% endfor 
  44.     %}>{{Label.text ?: ''}}</label> 
  45.     <input {% 
  46.         for attr, value in Input %}{% if attr not in (attribute(attribute(tfEls, 'Input'), 'excludes') ?? [])
  47.             %}{{ attr }}{% 
  48.             if value is not same as(true) 
  49.                 %}="{{ value|replace( { '~' :  attribute(attribute(attribute(tfEls, 'Input'), 'defaults'), attr) ?? '' } ) }}"{% 
  50.             endif
  51.             %} {% 
  52.         endif %}{% endfor 
  53.     %}/>
  54.     <span {% 
  55.         for attr, value in Error %}{% if attr not in (attribute(attribute(tfEls, 'Error'), 'excludes') ?? [])
  56.             %}{{ attr }}{% 
  57.             if value is not same as(true) 
  58.                 %}="{{ value|replace( { '~' :  attribute(attribute(attribute(tfEls, 'Error'), 'defaults'), attr) ?? '' } ) }}"{% 
  59.             endif
  60.             %} {% 
  61.         endif %}{% endfor 
  62.     %}>{{Error.text ?: ''}}</span> 
  63. </div>
  64. {% endwith %}