public static ComponentBuilder <MvcBootstrapConfig <TModel>, Select> Select <TComponent, TModel>( this BootstrapHelper <MvcBootstrapConfig <TModel>, TComponent> helper, string name, string label, IEnumerable <SelectListItem> selectList) where TComponent : Component, ICanCreate <Select> { return(helper.Select(name, label) .AddOptions(selectList)); }
public static ComponentBuilder <MvcBootstrapConfig <TModel>, Select> SelectFor <TComponent, TModel, TValue>( this BootstrapHelper <MvcBootstrapConfig <TModel>, TComponent> helper, Expression <Func <TModel, TValue> > expression, IEnumerable <SelectListItem> selectList = null) where TComponent : Component, ICanCreate <Select> { ModelMetadata metadata = ModelMetadata.FromLambdaExpression(expression, helper.GetConfig().HtmlHelper.ViewData); string expressionText = ExpressionHelper.GetExpressionText(expression); string name = GetControlName(helper, expressionText); string label = GetControlLabel(metadata, expressionText); return(helper.Select(name, label, selectList)); }
public static ComponentBuilder <MvcBootstrapConfig <TModel>, Select> SelectFor <TComponent, TModel, TValue>( this BootstrapHelper <MvcBootstrapConfig <TModel>, TComponent> helper, Expression <Func <TModel, TValue> > expression, IEnumerable <SelectListItem> selectList = null) where TComponent : Component, ICanCreate <Select> { ModelMetadata metadata = ModelMetadata.FromLambdaExpression(expression, helper.GetConfig().HtmlHelper.ViewData); string expressionText = ExpressionHelper.GetExpressionText(expression); string name = GetControlName(helper, expressionText); string label = GetControlLabel(metadata, expressionText); ComponentBuilder <MvcBootstrapConfig <TModel>, Select> builder = helper.Select(name, label); if (metadata.Model != null && !string.IsNullOrEmpty(name)) { // Add the model value before adding options so they'll get selected on a match builder.GetComponent().ModelValue = metadata.Model.ToString(); } return(builder.AddOptions(selectList)); }
public static ComponentBuilder <MvcBootstrapConfig <TModel>, FormButton> ButtonFor <TComponent, TModel, TValue>( this BootstrapHelper <MvcBootstrapConfig <TModel>, TComponent> helper, Expression <Func <TModel, TValue> > expression, params string[] options) where TComponent : Component, ICanCreate <FormButton> { var metadata = ModelMetadata.FromLambdaExpression(expression, helper.GetConfig().HtmlHelper.ViewData); string expressionText = ExpressionHelper.GetExpressionText(expression); var name = helper.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(expressionText); string name = GetControlName(helper, expressionText); string label = GetControlLabel(metadata, expressionText); ComponentBuilder <MvcBootstrapConfig <TModel>, Select> builder = helper.Select(name, label); if (metadata.Model != null && !string.IsNullOrEmpty(name)) { // Add the model value before adding options so they'll get selected on a match builder.GetComponent().ModelValue = metadata.Model.ToString(); } return(builder.AddOptions(options)); }