mcintyre321 / FormFactory

MVC5, Core or standalone - Generate rich HTML5 forms from your ViewModels, or build them programatically
http://formfactoryaspmvc.azurewebsites.net/
MIT License
304 stars 102 forks source link

LabelOnRightAttribute usage #37

Closed Budsy closed 7 years ago

Budsy commented 7 years ago

I tried adding new FormFactory.Attributes.LabelOnRightAttribute() to the GetCustomAttributes field list (in declarative programmable model example) for a checkbox. It rendered the following:

"if (Model.GetCustomAttributes().OfType ().Any()) { } else //if not required, then it is possible to post a false value, which means we need a hidden field as unchecked checkboxes aren't posted. sigh. { } Checkbox label here"

This wasn't quite what I expected. Is there a correct way to get the label for a checkbox to render to the right of the box? A checkbox works great with the default label on the left.

mcintyre321 commented 7 years ago

Thanks for trying out. It seems to be rendering the raw template instead of rendering it properly. There may be a missing @ somewhere.

Could you fork the project and add your code to the examples and I will take a look ASAP? On Sat, 4 Feb 2017 at 05:09, Budsy notifications@github.com wrote:

I tried adding new FormFactory.Attributes.LabelOnRightAttribute() to the GetCustomAttributes field list (in declarative programmable model example) for a checkbox. It rendered the following:

"if (Model.GetCustomAttributes().OfType ().Any()) { } else //if not required, then it is possible to post a false value, which means we need a hidden field as unchecked checkboxes aren't posted. sigh. { } Checkbox label here"

This wasn't quite what I expected. Is there a correct way to get the label for a checkbox to render to the right of the box? A checkbox works great with the default label on the left.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/mcintyre321/FormFactory/issues/37, or mute the thread https://github.com/notifications/unsubscribe-auth/AAQ0-mK2WRvdwSVUR7tlec7eLDv_E4XMks5rZAgegaJpZM4L3C0m .

Budsy commented 7 years ago

I put my code into the Mvc Examples Index demo page on a fork. Currently I'm going to try to compile your source and track this down. ...have to upgrade my VS first. ;-)

Budsy commented 7 years ago

I found the bug and made a fix in FormFactory/Views/Shared/FormFactory/Property.System.Boolean.cshtml . It was, as you surmised, missing the @ on the if keyword, needed after the html <label> tag line in the View markup file. I compiled the Dll with this change and am using it in my project now. Works like a charm.

mcintyre321 commented 7 years ago

thanks for the PR!