DmitryEfimenko / TwitterBootstrapMvc

Fluent implementation of ASP.NET-MVC HTML helpers for Twitter Bootstrap.
Apache License 2.0
223 stars 79 forks source link

FormGroup control CustomLabel cant set "for" attribute #290

Closed alreadytakenname closed 10 years ago

alreadytakenname commented 10 years ago

Hi Dmitry!

We are using TwitterBootstrapMVC - MVC4 version 3.12.3 to render bootstrap markup. We came across a situation where we needed to use CustomLabel for a CustomControl in a FormGroup however we were not able to set the generated "label" tag's "for" attribute. Booth overloads for CustomLabel render the content inside a label with an empty "for" attribute.

Could you look into this for us? Thanks in advance!

DmitryEfimenko commented 10 years ago

would that be ok, if there was an overload that took a second parameter to set the for attribute:

.CustomLabel("My Label", "fieldId")
alreadytakenname commented 10 years ago

Hi Dimitry!

Having a second parameter for the for attribute would mimic the default html helper's behavior.

@Html.Label("targetId", "Text")

renders

<label for="targetId">Text</label>

An overload like that would solve our problem.

DmitryEfimenko commented 10 years ago

I can't do that exactly this way. The .CustomLabel() helper has been in the BMVC for a long time, so switching parameters would mean breaking existing code for lots of people.

alreadytakenname commented 10 years ago

I understand and it doesn't realy matter in which order we have to provide the parameters. It would be nice if you could add this feature in an upcoming release.

DmitryEfimenko commented 10 years ago

The support for this is implemented. Use chain methods like so:

.CustomLabel("label").HtmlAttributes(new { for = "idOfInput" })