Last active
November 16, 2018 21:22
-
-
Save vertonghenb/1b5608bf344f08e75e5781b4311187cb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// In the form you can multiple of these: | |
<MTextField Text=@Text | |
IsAutofocus=@IsAutofocus | |
IsMultiline=@IsMultiline | |
Lines=@Lines | |
Value=@Value | |
Placeholder=@Placeholder | |
Suffix=@Suffix | |
OnChange=@OnChange | |
InputType=@InputType | |
Feedback=@(Errors == null ? "" : Errors.GetValueOrDefault(PropertyName)) | |
Help=@Help/> | |
// MTextField.cshtml | |
@using Metronic.Enums | |
@if (!string.IsNullOrEmpty(Text)) | |
{ | |
<label>@Text</label> | |
} | |
@if (IsMultiline) | |
{ | |
<textarea class=@GetClass() | |
rows="@Lines" | |
placeholder="@Placeholder" | |
readonly=@IsReadOnly | |
required=@IsRequired | |
autofocus=@IsAutofocus | |
onchange=@OnChange | |
disabled="@IsDisabled">@Value</textarea> | |
} | |
else | |
{ | |
<div class=@GetClassForGroup()> | |
@if (!string.IsNullOrEmpty(Prefix)) | |
{ | |
<div class="input-group-prepend"> | |
<span class="input-group-text" id="basic-addon2">@Prefix</span> | |
</div> | |
} | |
<input type="@InputType" | |
class=@GetClass() | |
placeholder=@Placeholder | |
autofocus=@IsAutofocus | |
value=@Value | |
onchange=@OnChange | |
format-value=@(InputType == EInputType.Date ? "yyyy-MM-dd" : null) | |
readonly=@IsReadOnly | |
required=@IsRequired | |
disabled=@IsDisabled /> | |
@if (!string.IsNullOrEmpty(Suffix)) | |
{ | |
<div class="input-group-append"> | |
<span class="input-group-text" id="basic-addon2">@Suffix</span> | |
</div> | |
} | |
</div> | |
} | |
@if (!string.IsNullOrEmpty(Feedback)) | |
{ | |
<div class="form-control-feedback">@Feedback</div> | |
} | |
@if (!string.IsNullOrEmpty(Help)) | |
{ | |
<span class="m-form__help">@Help</span> | |
} | |
@functions{ | |
#region Parameters | |
[Parameter] protected string Text { get; set; } | |
[Parameter] protected string Placeholder { get; set; } | |
[Parameter] protected string Help { get; set; } | |
[Parameter] protected string Feedback { get; set; } | |
[Parameter] protected EInputType InputType { get; set; } = EInputType.Text; | |
[Parameter] protected string Value { get; set; } | |
[Parameter] protected string Prefix { get; set; } | |
[Parameter] protected string Suffix { get; set; } | |
[Parameter] protected Action<UIChangeEventArgs> OnChange { get; set; } | |
[Parameter] protected bool IsRequired { get; set; } = false; | |
[Parameter] protected bool IsReadOnly { get; set; } = false; | |
[Parameter] protected bool IsDisabled { get; set; } = false; | |
[Parameter] protected bool IsAutofocus { get; set; } = false; | |
// Textarea | |
[Parameter] protected int Lines { get; set; } = 2; | |
[Parameter] protected bool IsMultiline { get; set; } = false; | |
[Parameter] protected Action<string> ValueChanged { get; set; } | |
#endregion | |
#region Functions | |
protected override string GetClass() | |
{ | |
string defaultClass = "form-control m-input"; | |
return defaultClass; | |
} | |
#endregion | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment