Skip to content

Commit f98bb8b

Browse files
authored
Merge pull request #8 from TechnologyEnhancedLearning/Fix/TD-1203-add-placeholder-to-the-text-input-control
TD-1203 add-placeholder-to-the-text-input-control
2 parents 5dadcdf + 6ef9fe1 commit f98bb8b

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

NHSUKViewComponents.Web/ViewComponents/TextInputViewComponent.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public class TextInputViewComponent : ViewComponent
1818
/// <param name="autocomplete">Leave blank to set no autocomplete on the input element.</param>
1919
/// <param name="cssClass"></param>
2020
/// <param name="required"></param>
21+
/// <param name="placeholderText"></param>
2122
/// <returns></returns>
2223
public IViewComponentResult Invoke(
2324
string aspFor,
@@ -28,7 +29,8 @@ public IViewComponentResult Invoke(
2829
string hintText,
2930
string autocomplete,
3031
string cssClass,
31-
bool required
32+
bool required,
33+
string? placeholderText = null
3234
)
3335
{
3436
var model = ViewData.Model;
@@ -50,9 +52,11 @@ bool required
5052
errorMessages,
5153
string.IsNullOrEmpty(cssClass) ? null : cssClass,
5254
string.IsNullOrEmpty(hintText) ? null : hintText,
53-
required
55+
required,
56+
string.IsNullOrEmpty(placeholderText) ? null : placeholderText
5457
);
5558
return View(textBoxViewModel);
5659
}
5760
}
61+
5862
}

NHSUKViewComponents.Web/ViewModels/TextInputViewModel.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ public TextInputViewModel(
1616
IEnumerable<string> errorMessages,
1717
string? cssClass = null,
1818
string? hintText = null,
19-
bool required = false
19+
bool required = false,
20+
string? placeholder = null
2021
)
2122
{
2223
var errorMessageList = errorMessages.ToList();
@@ -33,6 +34,7 @@ public TextInputViewModel(
3334
Required = required;
3435
ErrorMessages = errorMessageList;
3536
HasError = errorMessageList.Any();
37+
PlaceHolder = placeholder;
3638
}
3739

3840
public string Id { get; set; }
@@ -47,5 +49,7 @@ public TextInputViewModel(
4749
public bool Required { get; set; }
4850
public IEnumerable<string> ErrorMessages { get; set; }
4951
public readonly bool HasError;
52+
public string? PlaceHolder { get; set; }
5053
}
54+
5155
}

0 commit comments

Comments
 (0)