General usage of type in input fields

This commit is contained in:
nupplaPhil 2019-12-05 21:42:33 +01:00
parent 47505aceec
commit c28f1fec51
No known key found for this signature in database
GPG key ID: D8365C3D36B77D90
3 changed files with 4 additions and 4 deletions

View file

@ -80,7 +80,7 @@ Field parameter:
### field_input.tpl
A single line input field for textual input.
A single line input field for any type of input.
Field parameter:
0. Name of the field,
@ -89,7 +89,7 @@ Field parameter:
3. Help text for the input box,
4. if set to "required" modern browser will check that this input box is filled when submitting the form,
5. if set to "autofocus" modern browser will put the cursur into this box once the page is loaded,
6. if set to "email", "url" or "int" modern browser will check that the filled in value corresponds to an email address, URL or numeric.
6. if set, it will be used for the input type, default is `text` (possible types: https://www.w3schools.com/html/html_form_input_types.asp).
### field_intcheckbox.tpl

View file

@ -64,7 +64,7 @@ class Verify extends BaseModule
'$errors_label' => L10n::tt('Error', 'Errors', count(self::$errors)),
'$errors' => self::$errors,
'$recovery_message' => L10n::t('Dont have your phone? <a href="%s">Enter a two-factor recovery code</a>', '2fa/recovery'),
'$verify_code' => ['verify_code', L10n::t('Please enter a code from your authentication app'), '', '', 'required', 'autofocus placeholder="000000"', 'int'],
'$verify_code' => ['verify_code', L10n::t('Please enter a code from your authentication app'), '', '', 'required', 'autofocus placeholder="000000"', 'number'],
'$verify_label' => L10n::t('Verify code and complete login'),
]);
}

View file

@ -1,7 +1,7 @@
<div class="field input" id="wrapper_{{$field.0}}">
<label for="id_{{$field.0}}">{{$field.1}}</label>
<input{{if $field.6 eq 'email'}} type="email"{{elseif $field.6 eq 'url'}} type="url"{{elseif $field.6 eq 'int'}} type="number"{{else}} type="text"{{/if}} name="{{$field.0}}" id="id_{{$field.0}}" value="{{$field.2 nofilter}}"{{if $field.4 eq 'required'}} required{{/if}}{{if $field.5 eq "autofocus"}} autofocus{{elseif $field.5}} {{$field.5 nofilter}}{{/if}} aria-describedby="{{$field.0}}_tip">
<input{{if $field.6}} type="{{$field.6}}"{{else}} type="text"{{/if}} name="{{$field.0}}" id="id_{{$field.0}}" value="{{$field.2 nofilter}}"{{if $field.4 eq 'required'}} required{{/if}}{{if $field.5 eq "autofocus"}} autofocus{{elseif $field.5}} {{$field.5 nofilter}}{{/if}} aria-describedby="{{$field.0}}_tip">
{{if $field.3}}
<span class="field_help" role="tooltip" id="{{$field.0}}_tip">{{$field.3 nofilter}}</span>
{{/if}}