Closed fairking closed 7 years ago
Sorry you're having problems. It's very challenging to wrap a framework as big as Bootstrap successfully without any edge cases. As you've discovered there are certainly still some bugs, mostly related to integrating with the MVC view model and HtmlHelper
class. That said, I (and many others) have been using it in production scenarios for quite a while. I guess it all depends on the demands of your production environment and if you'll tend to encounter these edge cases (or care to work through them).
I certainly welcome any help you can give. As with most OSS, this is a volunteer project. If you run across bugs or output that doesn't match your expectations, PRs are always welcome :smile:
Hi @daveaglick. Thanks a lot for your help. I'm trying to create some kind of helper, but I'm using HtmlHelper
and TagBuilder
at the moment:
As you can see most of form groups is just one line.
The helper looks like that:
public class FormGroupExtensionConfig<TModel, TValue> : BaseExtensionConfig<TModel, TValue>
{
public FormGroupExtensionConfig(HtmlHelper<TModel> helper, Expression<Func<TModel, TValue>> expression)
: base(helper, expression)
{
RequiredLabel = true;
}
protected bool RequiredLabel { get; protected set; }
protected bool Tooltip { get; protected set; }
protected string TooltipText { get; protected set; }
...
public FormGroupExtensionConfig<TModel, TValue> WithNoRequiredLabel(bool requiredLabel = false)
{
RequiredLabel = requiredLabel;
return this;
}
public FormGroupExtensionConfig<TModel, TValue> WithTooltip(string tooltip = "")
{
Tooltip = true;
TooltipText = tooltip;
return this;
}
...
public override string ToHtmlString()
{
var requiredLabelCss = RequiredLabel && Expression.IsRequired() ? " required" : "";
var horizontalLabelCss = Horizontal ? " col-md-4" : "";
var horizontalWrapperCss = Horizontal ? " col-md-7" : "";
var displayWrapperCss = Display ? " form-control-static" : "";
var controlCss = NoFormControlCss ? "" : " form-control";
var groupCss = Fixed ? "group-fixed" : "";
// FormGroup
var formGroup = new TagBuilder("div")
.AddAttribute("id", Helper.IdFor(Expression).ToString() + "_FormGroup")
.AddCss("form-group")
.AddCss(groupCss);
// Label
if (!NoLabel)
{
formGroup
.AddChild(
Label != null
? Helper.LabelFor(Expression, Label, new { @class = "control-label" + requiredLabelCss + horizontalLabelCss })
: Helper.LabelFor(Expression, new { @class = "control-label" + requiredLabelCss + horizontalLabelCss })
);
}
else if (Horizontal)
{
formGroup
.AddChild(new TagBuilder("div").AddCss(horizontalLabelCss), TagRenderMode.Normal);
}
...
I hope your framework will grow and expand in the best way. I'm rushing with some my project so I don't have too much time to understand and improve fluentbootstrap. - I've got hungry kids and huge taxes at the moment. :-)
Cheers.
Can the Label not be generated when it's empty?
Result:![20161116_1750](https://cloud.githubusercontent.com/assets/13495631/20642241/7d98056a-b401-11e6-9465-659f7943de4a.png)
Also I can not understand why SetMd renders additional div. There are lot of inconvenience during coding by Fluent Bootstrap. I've done some tests around and found it's not ready to be used in production. Some things just don't allow me to do what I exactly want.
Thanks.