MRCollective / ChameleonForms

Shape-shifting your forms experience in ASP.NET Core MVC
MIT License
254 stars 56 forks source link

With the bootstrap IFieldConfiguration, can you add a class to the "form group" div? #79

Closed nootn closed 10 years ago

nootn commented 10 years ago

Is there a way with ChameleonForms.TwitterBootstrap3 to add an extra class to the "form-group" div?

E.g to make it a particular grid width, you would want to do something like: <div class="form-group col-xs-4">

On the IFieldConfiguration interface it only lets you add a class to the label, control or validation but not the group.

If there is not a way could you please add it? The current workaround for me is to add it to the control, then in the document ready I use jquery to "move" it :/

MattDavies commented 10 years ago

Hey Andrew,

Thanks for putting this request in!

Will add it to our enhancements list, and take a look as soon as possible. In the meantime, feel free to take a stab at a pull request yourself and leave a note here if you have any issues - always happy to help point you in the right direction.

robdmoore commented 10 years ago

See https://trello.com/c/Z5l7XgAe/55-ability-to-specify-html-attributes-for-things-other-than-the-field-element (was already on the backlog). Would be good to find a template agnostic way of doing this - maybe a .AddFieldContainerClass() method? Would you ever need to add more than a class? Do we need to expose the ability to add other HTML attributes?

nootn commented 10 years ago

Yep ".AddFieldContainerClass()" would work. Currently there is no need for other attributes, but I guess along the same lines it could have ".AddFieldContainerAttribute(name, value)"? Do you have something like that on the other items (label, control, validation)?

robdmoore commented 10 years ago

Currently there is the ability to add a class to the label (and from memory possibly the validation errors too) via a similar method and any arbitrary html attribute to the control itself.

If we were to add something to do arbitrary attributes to other things then we would probably want to reuse the HtmlAttributes class, but it's tricky to get that working fluently without being confusing.

robdmoore commented 10 years ago

FYI This has now been completed - thanks @cuzzlor.

Version 1.1.0.7 has been released to NuGet: http://www.nuget.org/packages/chameleonforms