public ITextAreaComponent <TProperty> TextAreaFor <TProperty>(Expression <Func <TViewModel, TProperty> > property, TViewModel entity) { var textAreaComponent = new TextAreaComponent <TViewModel, TProperty>(); InitializeComponent(textAreaComponent, entity, property); return(textAreaComponent); }
protected internal virtual IFormComponent <IFormComponentInput> CreateTextInputComponent(string text, IModelMetadata modelMetadata) { if (modelMetadata == null) { throw new ArgumentNullException(nameof(modelMetadata)); } IFormComponent <IFormComponentInput> textInputComponent; var id = this.HtmlIdFactory.Create(modelMetadata.ContainerType.Name + modelMetadata.PropertyName + "Input"); var dataType = modelMetadata.GetDataType(); if (dataType != null && dataType.Value == DataType.MultilineText) { textInputComponent = new TextAreaComponent(modelMetadata.GetDisplayName(), this.HttpEncoder, id, modelMetadata.PropertyName, modelMetadata.IsRequired, text); } else { textInputComponent = new InputComponent(modelMetadata.GetDisplayName(), this.HttpEncoder, id, modelMetadata.PropertyName, modelMetadata.IsRequired, InputType.Text, text); } if (!string.IsNullOrWhiteSpace(modelMetadata.Watermark)) { textInputComponent.Input.SetAttribute(HtmlAttributeKey.Placeholder, modelMetadata.Watermark); } if (!string.IsNullOrEmpty(this.Settings.ComponentClass)) { textInputComponent.AddClass(this.Settings.ComponentClass); } if (!string.IsNullOrEmpty(this.Settings.TextInputClass)) { textInputComponent.Input.AddClass(this.Settings.TextInputClass); } foreach (var additionalValue in modelMetadata.AdditionalValues) { textInputComponent.Input.SetAttribute(additionalValue.Key, additionalValue.Value); } this.AddValidationClassIfNecessary(textInputComponent, modelMetadata.PropertyName); return(textInputComponent); }