In EPiServer 7.5, I've created a NewsArticle model that has several properties for various text fields. A few of these properties have StringLength limitations. For example, the title for a news article is decorated like so:
[Display(
Order = 10,
Name = "Title (Headline)",
Description = "The article's title (headline). Title also appears in the browser tab.",
Prompt = "Article headline or title",
GroupName = SystemTabNames.Content
)]
[Required]
[StringLength(100)]
public override string Title { get; set; }
When adding a new NewsArticle page, I would like to display the input as a longer field than the default width field that the browser displays for elements.
Can I apply a class or style to that will operate on that field when it's rendered in the Add Page interface? Or is there some property that can decorate the property which will make it a longer length?
Here is a screen shot of the interface that I'm referring to. I want to make that Title field wider on that form.
It's quite easy to accomplish with a custom EditorDescritor/UI hint.
Create an editor descriptor (inherit EditorDescriptor), override the ModifyMetadata method, and set:
metadata.EditorConfiguration.Add("style", "width: 300px");
That will add a "style" attribute to the "input" element of the editor, making the textbox wider.
For example, the following will add this to all string properties, without needing to add a UIHint attribute, making textboxes for string properties 300 pixels wide: