<commit_before>@*
Text input field using Component Library Styles as  documented:
    Label: http://hmrc.github.io/assets-frontend/section-label.html
    Input http://hmrc.github.io/assets-frontend/section-text-input.html

    @param field Field The form field the input value represents
    @param args options arguments for the template
            '_label -> Text for the field label before the input
            '_labelSuffix -> Text for the field label after the input
            '_labelClass -> Label Modifier class
            '_inputClass -> Modifier class for the input class, includes:
                input--xxsmall, input--xsmall, input--small,  input--normal,
                input--fullwidth, input--no-spinner, input--cleared,
                input--link
*@
@(field: Field, args: (Symbol, Any)*)(implicit lang: Lang = Lang("en"))
@import selfservicetimetopay.helpers.forms.fieldErrors
@import selfservicetimetopay.helpers.labelWrap
@import views.html.helper.FieldElements
@argsMap = @{ args.toMap }
@elements = @{ new FieldElements(field.id, field, null, argsMap, lang) }
@value = @{ field.value match { case Some(x) => x case None => "" case x => x }}
@wrapperClass = @{
    var w = Seq.empty ++ argsMap.getOrElse('_labelClass, "").asInstanceOf[String].split(" ")
    w = if (field.hasErrors) w :+ "form-field--error" else w
    w.mkString(" ")
}
@inputClass = @{
    var c:String = argsMap.getOrElse('_inputClass, "").asInstanceOf[String]
    c = if(field.hasErrors) c + " error-field" else c
    c.trim
}
@labelWrap('labelText -> argsMap.getOrElse('label, ""), 'for -> elements.field.name, '_modifierClass -> wrapperClass){
    <input type="text"@if(inputClass.nonEmpty){ class="@inputClass" } name="@elements.field.name" id="@elements.field.name" value="@value"
        @if( elements.args.contains('_dataAttributes) ){ @elements.args.get('_dataAttributes)}
        @if( elements.args.get('_autoComplete) ){ autocomplete="@elements.args.get('_autoComplete)" }
        @if(elements.args.get('_error_id).isDefined) { aria-labeledby="@elements.args.get('_error_id)" }
        @if(elements.args.get('_hintId).isDefined) { aria-describedby="@elements.args.get('_hintId)" }
        @if(elements.args.get('_maxlength).isDefined) { maxlength="@elements.args.get('_maxlength)" }
        @if(elements.args.get('_max).isDefined) { max="@elements.args.get('_max)" }
        @if(elements.args.get('_pattern).isDefined) { pattern="@elements.args.get('_pattern)" }
        @if(elements.args.get('_title).isDefined) { title="@elements.args.get('_title)" }
        @if(elements.args.get('_required).isDefined) { required }
        @if(elements.args.get('datalist).isDefined) { list="@{elements.field.name}_datalist" }
    />
    @argsMap.getOrElse('labelSuffix, "")
    @if(elements.args.get('datalist).isDefined) {
        <datalist id="@{elements.field.name}_datalist">
            @elements.args.get('datalist).get.asInstanceOf[Seq[String]].map { v:String => <option value="@v"/>
            }
        </datalist>
    }
    @fieldErrors(field)
}

<commit_msg>SSTTP-1017 changed order of messages so error message will display on top<commit_after>@*
Text input field using Component Library Styles as  documented:
    Label: http://hmrc.github.io/assets-frontend/section-label.html
    Input http://hmrc.github.io/assets-frontend/section-text-input.html

    @param field Field The form field the input value represents
    @param args options arguments for the template
            '_label -> Text for the field label before the input
            '_labelSuffix -> Text for the field label after the input
            '_labelClass -> Label Modifier class
            '_inputClass -> Modifier class for the input class, includes:
                input--xxsmall, input--xsmall, input--small,  input--normal,
                input--fullwidth, input--no-spinner, input--cleared,
                input--link
*@
@(field: Field, args: (Symbol, Any)*)(implicit lang: Lang = Lang("en"))
@import selfservicetimetopay.helpers.forms.fieldErrors
@import selfservicetimetopay.helpers.labelWrap
@import views.html.helper.FieldElements
@argsMap = @{ args.toMap }
@elements = @{ new FieldElements(field.id, field, null, argsMap, lang) }
@value = @{ field.value match { case Some(x) => x case None => "" case x => x }}
@wrapperClass = @{
    var w = Seq.empty ++ argsMap.getOrElse('_labelClass, "").asInstanceOf[String].split(" ")
    w = if (field.hasErrors) w :+ "form-field--error" else w
    w.mkString(" ")
}
@inputClass = @{
    var c:String = argsMap.getOrElse('_inputClass, "").asInstanceOf[String]
    c = if(field.hasErrors) c + " error-field" else c
    c.trim
}
@labelWrap('for -> elements.field.name, '_modifierClass -> wrapperClass){
    @fieldErrors(field)
    @argsMap.getOrElse('label, "")
    <input type="text"@if(inputClass.nonEmpty){ class="@inputClass" } name="@elements.field.name" id="@elements.field.name" value="@value"
        @if(elements.args.contains('_dataAttributes) ){ @elements.args.get('_dataAttributes)}
        @if(elements.args.get('_autoComplete) ){ autocomplete="@elements.args.get('_autoComplete)" }
        @if(elements.args.get('_error_id).isDefined) { aria-labeledby="@elements.args.get('_error_id)" }
        @if(elements.args.get('_hintId).isDefined) { aria-describedby="@elements.args.get('_hintId)" }
        @if(elements.args.get('_maxlength).isDefined) { maxlength="@elements.args.get('_maxlength)" }
        @if(elements.args.get('_max).isDefined) { max="@elements.args.get('_max)" }
        @if(elements.args.get('_pattern).isDefined) { pattern="@elements.args.get('_pattern)" }
        @if(elements.args.get('_title).isDefined) { title="@elements.args.get('_title)" }
        @if(elements.args.get('_required).isDefined) { required }
        @if(elements.args.get('datalist).isDefined) { list="@{elements.field.name}_datalist" }
    />
    @argsMap.getOrElse('labelSuffix, "")
    @if(elements.args.get('datalist).isDefined) {
        <datalist id="@{elements.field.name}_datalist">
            @elements.args.get('datalist).get.asInstanceOf[Seq[String]].map { v:String => <option value="@v"/>
            }
        </datalist>
    }
}


{'fraction_non_alphanumeric': 0.16321243523316062, 'fraction_numerical': 0.0006476683937823834, 'mean_word_length': 3.616591928251121, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 32, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7591330', 'n_tokens_mistral': 1999, 'n_tokens_neox': 1953, 'n_words': 354}